From 2e8839de7c6658ed6e8b00985580d47e20c989e7 Mon Sep 17 00:00:00 2001 From: George Karpenkov Date: Tue, 13 Nov 2018 20:19:38 +0000 Subject: [PATCH] [lsan] [NFC] Change ARRAY_SIZE to internal_strnlen Calling ARRAY_SIZE on a char* will not actually compute it's size, but just the pointer size. A new Clang warning enabled by default warns about this. Replaced the call with internal_strnlen. Differential Revision: https://reviews.llvm.org/D54484 llvm-svn: 346792 --- compiler-rt/lib/lsan/lsan_common_mac.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/lsan/lsan_common_mac.cc b/compiler-rt/lib/lsan/lsan_common_mac.cc index 8dd247ca5f1e..f656ded1fff7 100644 --- a/compiler-rt/lib/lsan/lsan_common_mac.cc +++ b/compiler-rt/lib/lsan/lsan_common_mac.cc @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "sanitizer_common/sanitizer_platform.h" +#include "sanitizer_common/sanitizer_libc.h" #include "lsan_common.h" #if CAN_SANITIZE_LEAKS && SANITIZER_MAC @@ -116,7 +117,8 @@ static const char *kSkippedSecNames[] = { // Scans global variables for heap pointers. void ProcessGlobalRegions(Frontier *frontier) { - for (auto name : kSkippedSecNames) CHECK(ARRAY_SIZE(name) < kMaxSegName); + for (auto name : kSkippedSecNames) + CHECK(internal_strnlen(name, kMaxSegName) < kMaxSegName); MemoryMappingLayout memory_mapping(false); InternalMmapVector modules;