dbus_realloc: don't crash if realloc() returns NULL while using guards

Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41048
This commit is contained in:
Simon McVittie 2011-06-23 11:26:38 +01:00
parent 13c1292150
commit 1d89cad343

View file

@ -588,8 +588,11 @@ dbus_realloc (void *memory,
block = realloc (((unsigned char*)memory) - GUARD_START_OFFSET,
bytes + GUARD_EXTRA_SIZE);
old_bytes = *(dbus_uint32_t*)block;
if (block && bytes >= old_bytes)
if (block == NULL)
return NULL;
old_bytes = *(dbus_uint32_t*)block;
if (bytes >= old_bytes)
/* old guards shouldn't have moved */
check_guards (((unsigned char*)block) + GUARD_START_OFFSET, FALSE);