From 9e744d2bbdafbeb0b657bd906a332cf9d42c5545 Mon Sep 17 00:00:00 2001 From: jeffhuang Date: Thu, 7 May 2026 03:01:24 +0000 Subject: [PATCH] Fix LeakSanitizer leak in CrossNamespacePackTest Consumer::UnPack() returns an owning raw pointer (the generated code does `_o.release()`), so the caller must take ownership. The test added in #8948 stored the result in `auto`, leaking the ConsumerT and its nested allocations -- LSan reports 48 bytes in 4 allocations. Wrap in std::unique_ptr, matching the pattern already used for the other UnPack() call site at tests/test.cpp:298 (which deletes explicitly). --- tests/test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.cpp b/tests/test.cpp index 5a43546f53..13e9faddc8 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -1739,7 +1739,7 @@ void CrossNamespacePackTest() { fbb.Finish(foo::Consumer::Pack(fbb, &consumer)); auto* packed = flatbuffers::GetRoot(fbb.GetBufferPointer()); - auto unpacked = packed->UnPack(); + std::unique_ptr unpacked(packed->UnPack()); TEST_EQ(unpacked->c1->value, 42); TEST_EQ(unpacked->c2.size(), 1); TEST_EQ(unpacked->c2[0]->value, 99);