ref: 14dc9355bd71818cf01c1c690c1c91a0978ea9b8
parent: e2b59201d5049a8ad509b280e729a871756abc99
author: Tor Andersson <tor.andersson@artifex.com>
date: Wed Jun 12 13:23:38 EDT 2019
Issue 102: Fix ASAN build when using GCC. GCC's address sanitizer sets the __SANITIZE_ADDRESS__ macro instead.
--- a/jsstate.c
+++ b/jsstate.c
@@ -9,13 +9,14 @@
static void *js_defaultalloc(void *actx, void *ptr, int size)
{
-#if defined(__has_feature)
-#if __has_feature(address_sanitizer)
+#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
#endif
return realloc(ptr, (size_t)size);
}