]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: activity: use the new pointer to calculate the new size in realloc()
authorWilly Tarreau <w@1wt.eu>
Fri, 7 May 2021 06:01:35 +0000 (08:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 May 2021 06:01:35 +0000 (08:01 +0200)
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

index df8b9bdda081e9971612592201253d708a42524d..d058cfd74f27bc8d267019a72ed082e30af7f66d 100644 (file)
@@ -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) {