From 940e8a344548016451775ee84321dc4cc067b5ef Mon Sep 17 00:00:00 2001 From: Jesse McKenna Date: Tue, 13 Feb 2024 10:08:20 -0800 Subject: [PATCH] Fix leaky CrashpadInfo test CrashpadInfo::AddUserDataMinidumpStream() and UpdateUserDataMinidumpStream() allocate memory for the newly added streams. This change makes the CrashpadInfo test free that allocated memory to prevent memory leaks from these tests. This is intended to fix the ASAN failures seen on crrev.com/c/5285881: https://ci.chromium.org/ui/p/chromium/builders/try/linux_chromium_asan_rel_ng/1839072/overview Bug: crashpad:474 Change-Id: I6e030291594d22e316942a58805a177ce448053b Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5292137 Reviewed-by: Mark Mentovai Commit-Queue: Jesse McKenna --- client/crashpad_info_test.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client/crashpad_info_test.cc b/client/crashpad_info_test.cc index 09799f14..8ea7f8a1 100644 --- a/client/crashpad_info_test.cc +++ b/client/crashpad_info_test.cc @@ -67,6 +67,17 @@ class CrashpadInfoTest : public testing::Test { ASSERT_EQ(nullptr, GetNext(current)); } + void TearDown() override { + // Free the list. The list lives until process exit in production, but must + // be freed in tests as multiple tests run in the same process. + auto current = GetCurrentHead(); + while (current) { + auto next = GetNext(current); + delete current; + current = next; + } + } + internal::UserDataMinidumpStreamListEntry* AddStream(uint32_t stream_type, const char* data) { return reinterpret_cast(