[asan] use internal_strcmp before asan_init is done. *may* fix asan issue #30
llvm-svn: 148726
This commit is contained in:
parent
2f6377cafe
commit
586ade114b
|
@ -235,6 +235,18 @@ char *internal_strncat(char *dst, const char *src, size_t n) {
|
|||
return dst;
|
||||
}
|
||||
|
||||
int internal_strcmp(const char *s1, const char *s2) {
|
||||
while (true) {
|
||||
unsigned c1 = *s1;
|
||||
unsigned c2 = *s2;
|
||||
if (c1 != c2) return (c1 < c2) ? -1 : 1;
|
||||
if (c1 == 0) break;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace __asan
|
||||
|
||||
// ---------------------- Wrappers ---------------- {{{1
|
||||
|
@ -490,10 +502,8 @@ char *WRAP(strcat)(char *to, const char *from) { // NOLINT
|
|||
|
||||
extern "C"
|
||||
int WRAP(strcmp)(const char *s1, const char *s2) {
|
||||
// strcmp is called from malloc_default_purgeable_zone()
|
||||
// in __asan::ReplaceSystemAlloc() on Mac.
|
||||
if (asan_init_is_running) {
|
||||
return real_strcmp(s1, s2);
|
||||
if (!asan_inited) {
|
||||
return internal_strcmp(s1, s2);
|
||||
}
|
||||
unsigned char c1, c2;
|
||||
size_t i;
|
||||
|
|
|
@ -70,6 +70,7 @@ void* internal_memchr(const void* s, int c, size_t n);
|
|||
int internal_memcmp(const void* s1, const void* s2, size_t n);
|
||||
char *internal_strstr(const char *haystack, const char *needle);
|
||||
char *internal_strncat(char *dst, const char *src, size_t n);
|
||||
int internal_strcmp(const char *s1, const char *s2);
|
||||
|
||||
void InitializeAsanInterceptors();
|
||||
|
||||
|
|
Loading…
Reference in New Issue