diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-06-23 11:26:38 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-02-21 15:07:56 +0000 |
commit | 1d89cad3436f9d7185798d27bc9b9211044b987c (patch) | |
tree | 2653e8b8a0a736e0ec1020b5b12685a808299581 | |
parent | 13c1292150c4f5d57527d11f5b92f5b955f9906e (diff) | |
download | dbus-1d89cad3436f9d7185798d27bc9b9211044b987c.tar.gz |
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
-rw-r--r-- | dbus/dbus-memory.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c index c5f46413..08698d43 100644 --- a/dbus/dbus-memory.c +++ b/dbus/dbus-memory.c @@ -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); |