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>
This commit is contained in:
niewei 2022-03-16 10:02:19 +08:00 committed by Boringssl LUCI CQ
parent 8c8e7a683f
commit f94a7ce599

View File

@ -180,11 +180,17 @@ void OPENSSL_free(void *orig_ptr) {
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) {