From 018d64ca814c876bb32d53dd2819f6325420d02f Mon Sep 17 00:00:00 2001 From: meteors117 Date: Fri, 18 Apr 2025 11:52:49 +0800 Subject: [PATCH] [Compiler-rt][HWASAN] fix memory_debug param initialization. Signed-off-by: meteors117 --- compiler-rt/lib/hwasan/hwasan.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp index 100ba39a7a29..db096a013ad7 100644 --- a/compiler-rt/lib/hwasan/hwasan.cpp +++ b/compiler-rt/lib/hwasan/hwasan.cpp @@ -425,9 +425,18 @@ __attribute__((constructor(0))) void __hwasan_init() { // OHOS_LOCAL begin if (flags()->memory_debug) { - flags()->max_malloc_fill_size = 256; - flags()->max_free_fill_size = 256; - flags()->heap_quarantine_max = 1024 + 1; + if (flags()->max_malloc_fill_size <= 0 || + flags()->max_malloc_fill_size > 1024) { + flags()->max_malloc_fill_size = 256; + } + if (flags()->max_free_fill_size <= 0 || + flags()->max_free_fill_size > 1024) { + flags()->max_free_fill_size = 256; + } + if (flags()->heap_quarantine_max <= 0 || + flags()->heap_quarantine_max > 65537) { + flags()->heap_quarantine_max = 1024 + 1; + } } // OHOS_LOCAL end -- Gitee