From f8b46e82a11e0c43cf38c57ff5ddeee8d0b67d6c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 23 Jun 2011 11:26:38 +0100 Subject: [PATCH 1/2] dbus_realloc: don't crash if realloc() returns NULL while using guards --- 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 ee40e82..16f54a6 100644 --- a/dbus/dbus-memory.c +++ b/dbus/dbus-memory.c @@ -587,8 +587,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); -- 1.7.6.3