[clang] bbc4a71 - [test] Fix leak in test
Vitaly Buka via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 16 12:41:21 PDT 2022
Author: Vitaly Buka
Date: 2022-07-16T12:41:12-07:00
New Revision: bbc4a71e413226798972a2180c306efade48ef4f
URL: https://github.com/llvm/llvm-project/commit/bbc4a71e413226798972a2180c306efade48ef4f
DIFF: https://github.com/llvm/llvm-project/commit/bbc4a71e413226798972a2180c306efade48ef4f.diff
LOG: [test] Fix leak in test
Added:
Modified:
clang/unittests/Interpreter/InterpreterTest.cpp
Removed:
################################################################################
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp
index 720e30fafca7e..494926f7c116d 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -234,8 +234,10 @@ static void *AllocateObject(TypeDecl *TD, Interpreter &Interp) {
<< std::hex << std::showbase << (size_t)Addr << ")" << Name << "();";
auto R = Interp.ParseAndExecute(SS.str());
- if (!R)
+ if (!R) {
+ free(Addr);
return nullptr;
+ }
return Addr;
}
@@ -291,6 +293,7 @@ TEST(IncrementalProcessing, InstantiateTemplate) {
typedef int (*TemplateSpecFn)(void *);
auto fn = (TemplateSpecFn)cantFail(Interp->getSymbolAddress(MangledName));
EXPECT_EQ(42, fn(NewA));
+ free(NewA);
}
} // end anonymous namespace
More information about the cfe-commits
mailing list