forked from osmocom/wireshark
wsutil: Add ws_assert_bounds()
This commit is contained in:
parent
adfb0b99c2
commit
cee1b443b5
|
@ -129,7 +129,7 @@ wmem_array_append(wmem_array_t *array, const void *in, guint count)
|
||||||
void *
|
void *
|
||||||
wmem_array_index(wmem_array_t *array, guint array_index)
|
wmem_array_index(wmem_array_t *array, guint array_index)
|
||||||
{
|
{
|
||||||
ws_assert(array_index < array->elem_count);
|
ws_assert_bounds(array_index < array->elem_count);
|
||||||
return &array->buf[array_index * array->elem_size];
|
return &array->buf[array_index * array->elem_size];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,4 +43,9 @@ WS_NORETURN void ws_assert_not_reached(void) {
|
||||||
abort();
|
abort();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ws_assert_bounds() is always enabled. For bounds check where the array
|
||||||
|
* size is known sometimes it's just not worth disabling assertions.
|
||||||
|
*/
|
||||||
|
#define ws_assert_bounds(expr) g_assert_true(expr)
|
||||||
|
|
||||||
#endif /* __WS_ASSERT_H__ */
|
#endif /* __WS_ASSERT_H__ */
|
||||||
|
|
Loading…
Reference in New Issue