From 14dc9355bd71818cf01c1c690c1c91a0978ea9b8 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 12 Jun 2019 17:23:38 +0200 Subject: [PATCH] Issue 102: Fix ASAN build when using GCC. GCC's address sanitizer sets the __SANITIZE_ADDRESS__ macro instead. --- jsstate.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jsstate.c b/jsstate.c index 10c25c5..75b7842 100644 --- 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); }