From 2639e2edc2cdc0546a83291e553c7423517f0a67 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 7 May 2021 08:01:35 +0200 Subject: [PATCH] BUG/MINOR: activity: use the new pointer to calculate the new size in realloc() When memory profiling is enabled, realloc() can occasionally get the area size wrong due to the wrong pointer being used to check the new size. When the old area gets unmapped in the operation, this may even result in a crash. There's no impact without memory profiling though. No backport is needed as this is exclusively 2.4-dev. --- src/activity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/activity.c b/src/activity.c index df8b9bd..d058cfd 100644 --- a/src/activity.c +++ b/src/activity.c @@ -276,7 +276,7 @@ void *realloc(void *ptr, size_t size) size_before = malloc_usable_size(ptr); ret = memprof_realloc_handler(ptr, size); - size = malloc_usable_size(ptr); + size = malloc_usable_size(ret); bin = memprof_get_bin(__builtin_return_address(0)); if (size > size_before) { -- 1.7.10.4