Fix 'radiff2 -g' crash

No all users of r_diff_buffers_distance() pass a pointer for 'distance'
argument. Check for NULL before assigning a value to it.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
This commit is contained in:
Pavel Borzenkov 2016-01-22 16:22:23 +03:00 committed by pancake
parent 1fc7dd4cf6
commit f1a9852362

View File

@ -199,8 +199,10 @@ R_API int r_diff_buffers_distance(RDiff *d, const ut8 *a, ut32 la, const ut8 *b,
return R_FALSE;
if (la == lb && !memcmp (a, b, la)) {
*distance = 0;
*similarity = 1.0;
if (distance != NULL)
*distance = 0;
if (similarity != NULL)
*similarity = 1.0;
return R_TRUE;
}
totalsz = sizeof(int*) * (lb+1);