Fix possible signed overflow

Shouldn't have led to problems so far, assuming sane overflow behavior
and sizeof (int) == sizeof (guint32), but better safe than sorry.

Change-Id: I1e154b311b9f0e3113bc9c7b4d8456ede16804ef
Reviewed-on: https://code.wireshark.org/review/24930
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
This commit is contained in:
Ahmad Fatoum 2017-12-21 16:23:42 +01:00 committed by Martin Kaiser
parent 5f0f2d610f
commit 5a3addd8eb
1 changed files with 10 additions and 2 deletions

View File

@ -672,10 +672,18 @@ epl_wmem_iarray_insert(epl_wmem_iarray_t *iarr, guint32 where, range_admin_t *da
g_array_append_vals(iarr->arr, data, 1);
}
static int u32cmp(guint32 a, guint32 b)
{
if (a < b) return -1;
if (a > b) return +1;
return 0;
}
static int
epl_wmem_iarray_cmp(const void *a, const void *b)
{
return *(const guint32*)a - *(const guint32*)b;
return u32cmp(*(const guint32*)a, *(const guint32*)b);
}
/** Makes array suitable for searching */
@ -716,7 +724,7 @@ find_in_range(const void *_a, const void *_b)
if (a->low <= b->high && b->low <= a->high) /* overlap */
return 0;
return a->low - b->low;
return u32cmp(a->low, b->low);
}
static void*