Revert D138095 Use InernalAlloc in DemangleCXXABI
Broke 2/3 tests on macOS which seem to be related to
`free(demangled_name)` in DemangleCXXABI.
GitOrigin-RevId: 06c74b5e7367b41e9b4ea3d74c971aace5681fb8
diff --git a/lib/asan/asan_globals.cpp b/lib/asan/asan_globals.cpp
index 2b4a9e0..b780128 100644
--- a/lib/asan/asan_globals.cpp
+++ b/lib/asan/asan_globals.cpp
@@ -149,8 +149,8 @@
if (g->odr_indicator == l->g->odr_indicator &&
(flags()->detect_odr_violation >= 2 || g->size != l->g->size) &&
!IsODRViolationSuppressed(g->name))
- ReportODRViolation(g, FindRegistrationSite(g), l->g,
- FindRegistrationSite(l->g));
+ ReportODRViolation(g, FindRegistrationSite(g),
+ l->g, FindRegistrationSite(l->g));
}
}
diff --git a/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp b/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
index d505d96..b223f6c 100644
--- a/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
+++ b/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
@@ -49,17 +49,12 @@
// FIXME: __cxa_demangle aggressively insists on allocating memory.
// There's not much we can do about that, short of providing our
// own demangler (libc++abi's implementation could be adapted so that
- // it does not allocate). For now, we just call it anyway, and use
- // InternalAlloc to prevent lsan error.
- if (&__cxxabiv1::__cxa_demangle) {
- if (char *demangled_name = __cxxabiv1::__cxa_demangle(name, 0, 0, 0)) {
- size_t size = internal_strlen(demangled_name) + 1;
- char *buf = (char *)InternalAlloc(size);
- internal_memcpy(buf, demangled_name, size);
- free(demangled_name);
- return buf;
- }
- }
+ // it does not allocate). For now, we just call it anyway, and we leak
+ // the returned value.
+ if (&__cxxabiv1::__cxa_demangle)
+ if (const char *demangled_name =
+ __cxxabiv1::__cxa_demangle(name, 0, 0, 0))
+ return demangled_name;
return name;
}