Skip to content

Commit bbc4a71

Browse files
committed
[test] Fix leak in test
1 parent 9ff36df commit bbc4a71

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clang/unittests/Interpreter/InterpreterTest.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,10 @@ static void *AllocateObject(TypeDecl *TD, Interpreter &Interp) {
234234
<< std::hex << std::showbase << (size_t)Addr << ")" << Name << "();";
235235

236236
auto R = Interp.ParseAndExecute(SS.str());
237-
if (!R)
237+
if (!R) {
238+
free(Addr);
238239
return nullptr;
240+
}
239241

240242
return Addr;
241243
}
@@ -291,6 +293,7 @@ TEST(IncrementalProcessing, InstantiateTemplate) {
291293
typedef int (*TemplateSpecFn)(void *);
292294
auto fn = (TemplateSpecFn)cantFail(Interp->getSymbolAddress(MangledName));
293295
EXPECT_EQ(42, fn(NewA));
296+
free(NewA);
294297
}
295298

296299
} // end anonymous namespace

0 commit comments

Comments
 (0)