mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-09 04:58:02 +02:00
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:
parent
13c1292150
commit
1d89cad343
1 changed files with 5 additions and 2 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue