From 9dd2b6a1c757b73d58da9aa1c5b2af59b98c6adb Mon Sep 17 00:00:00 2001 From: Cyril Hrubis Date: Sun, 22 Dec 2013 22:09:44 +0100 Subject: [PATCH] tst_preload: Fix realloc(NULL, size) case. In case the realloc() was called with NULL optr the code wrongly searched for the old chunk and caused crash. The fix is to return malloc(size) in this case instead. Signed-off-by: Cyril Hrubis --- tests/framework/tst_preload.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/framework/tst_preload.c b/tests/framework/tst_preload.c index 9436c2c0..42457aa0 100644 --- a/tests/framework/tst_preload.c +++ b/tests/framework/tst_preload.c @@ -235,6 +235,9 @@ void *realloc(void *optr, size_t size) if (!real_realloc) real_realloc = dlsym(RTLD_NEXT, "realloc"); + if (!optr) + return malloc(size); + switch (malloc_canary) { case MALLOC_CANARY_OFF: ptr = real_realloc(optr, size); -- 2.11.4.GIT