This commit is contained in:
Tim Flynn 2025-01-02 11:40:21 +00:00 committed by GitHub
commit 41a22e9896
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View file

@ -8,9 +8,10 @@
#include <AK/Platform.h>
#ifdef HAS_ADDRESS_SANITIZER
#if defined(HAS_ADDRESS_SANITIZER)
# include <sanitizer/lsan_interface.h>
extern "C" {
char const* __lsan_default_suppressions();
char const* __lsan_default_suppressions()
{
// Both Skia and Chromium suppress false positive FontConfig leaks
@ -20,3 +21,14 @@ char const* __lsan_default_suppressions()
}
}
#endif
namespace AK {
inline void perform_leak_sanitizer_checks()
{
#if defined(HAS_ADDRESS_SANITIZER)
__lsan_do_leak_check();
#endif
}
}

View file

@ -5,6 +5,8 @@
*/
#include <AK/Format.h>
#include <AK/LsanSuppressions.h>
#include <AK/ScopeGuard.h>
#include <AK/StringView.h>
#include <AK/Vector.h>
#include <LibMain/Main.h>
@ -41,10 +43,14 @@ int main(int argc, char** argv)
.argv = argv,
.strings = arguments.span(),
});
ScopeGuard guard { []() { AK::perform_leak_sanitizer_checks(); } };
if (result.is_error()) {
auto error = result.release_error();
warnln("\033[31;1mRuntime error\033[0m: {}", error);
return Main::return_code_for_errors();
}
return result.value();
}