mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-05 17:29:43 +08:00
Don't call realloc with size=0 to free data.
Newer versions of the C spec and POSIX have changed the behavior of realloc called with size 0 to be implementation defined.
This commit is contained in:
@@ -10,15 +10,10 @@
|
||||
|
||||
static void *js_defaultalloc(void *actx, void *ptr, int size)
|
||||
{
|
||||
#ifndef __has_feature
|
||||
#define __has_feature(x) 0
|
||||
#endif
|
||||
#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
|
||||
if (size == 0) {
|
||||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
return realloc(ptr, (size_t)size);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user