Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler-rt/lib/asan/asan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ namespace __asan {

static inline uptr MaybeRealStrnlen(const char *s, uptr maxlen) {
#if SANITIZER_INTERCEPT_STRNLEN
if (REAL(strnlen))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not != nullptr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried there might be edge cases where REAL(strnlen) is defined to be zero but not a pointer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is that possible if we call it in the line below? You can't call an integer, and it still needs to typecheck?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Australia, you can call 000 for emergency services.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to compare to nullptr: 220c33c

if (REAL(strnlen) != nullptr)
return REAL(strnlen)(s, maxlen);
# endif
return internal_strnlen(s, maxlen);
}

static inline uptr MaybeRealWcsnlen(const wchar_t* s, uptr maxlen) {
# if SANITIZER_INTERCEPT_WCSNLEN
if (REAL(wcsnlen))
if (REAL(wcsnlen) != nullptr)
return REAL(wcsnlen)(s, maxlen);
# endif
return internal_wcsnlen(s, maxlen);
Expand Down
Loading