Skip to content

Commit cea8ffa

Browse files
authored
[asan] Avoid -Wpointer-bool-conversion warning by comparing to nullptr (#164906)
The current code may trigger a compiler warning: ``` address of function 'wcsnlen' will always evaluate to 'true' [-Wpointer-bool-conversion] ``` Fix this by comparing to nullptr. The same fix is applied to strnlen for future-proofing.
1 parent 0e87811 commit cea8ffa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler-rt/lib/asan/asan_interceptors.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ namespace __asan {
5858

5959
static inline uptr MaybeRealStrnlen(const char *s, uptr maxlen) {
6060
#if SANITIZER_INTERCEPT_STRNLEN
61-
if (REAL(strnlen))
61+
if (REAL(strnlen) != nullptr)
6262
return REAL(strnlen)(s, maxlen);
6363
# endif
6464
return internal_strnlen(s, maxlen);
6565
}
6666

6767
static inline uptr MaybeRealWcsnlen(const wchar_t* s, uptr maxlen) {
6868
# if SANITIZER_INTERCEPT_WCSNLEN
69-
if (REAL(wcsnlen))
69+
if (REAL(wcsnlen) != nullptr)
7070
return REAL(wcsnlen)(s, maxlen);
7171
# endif
7272
return internal_wcsnlen(s, maxlen);

0 commit comments

Comments
 (0)