ASAN replaces malloc and free with its own implementation. Should not run jemalloc with ASAN simultaneously. Change-Id: I2ea3107178c11fe34978bb093737564e1222c0d5 Signed-off-by: niewei <niewei@xiaomi.com> Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/51945 Reviewed-by: Adam Langley <agl@google.com> Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/mem.c b/crypto/mem.c index d3b2112..15d3436 100644 --- a/crypto/mem.c +++ b/crypto/mem.c
@@ -180,11 +180,17 @@ size_t size = *(size_t *)ptr; OPENSSL_cleanse(ptr, size + OPENSSL_MALLOC_PREFIX); + +// ASan knows to intercept malloc and free, but not sdallocx. +#if defined(OPENSSL_ASAN) + free(ptr); +#else if (sdallocx) { sdallocx(ptr, size + OPENSSL_MALLOC_PREFIX, 0 /* flags */); } else { free(ptr); } +#endif } void *OPENSSL_realloc(void *orig_ptr, size_t new_size) {