This reverts commit
d4b604baeadbb2498e4f2c3e260260eed210f5d6.
When realloc() is called, the extra memory between the originally
requested size and the end of malloc_usable_size() isn't copied. (at
least with the version of glibc that currently ships on Arch Linux)
As a result, some elements get lost and use uninitialized memory, most
commonly 0, and can lead to crashes.
fixes #12384
/* SPDX-License-Identifier: LGPL-2.1+ */
-#include <malloc.h>
#include <stdint.h>
#include <string.h>
return NULL;
*p = q;
- *allocated = _unlikely_(size == 0) ? newalloc : malloc_usable_size(q) / size;
+ *allocated = newalloc;
return q;
}