mirror of
https://github.com/yuzu-emu/breakpad
synced 2024-11-25 23:57:47 +00:00
module_unittest: fix memory leak
`AddFunction` only takes ownership of the pointer passed to it if it returns true. Since it returns false when adding `function2`, we need to free it. Bug: b:235999011 Change-Id: I11984103c2c153ff0daf2c9690f9c88d04a2131b Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3756732 Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
parent
4b7984b351
commit
0b1ffaa153
1 changed files with 4 additions and 1 deletions
|
@ -418,7 +418,10 @@ TEST(Construct, DuplicateFunctions) {
|
||||||
Module::Function* function2 = generate_duplicate_function("_without_form");
|
Module::Function* function2 = generate_duplicate_function("_without_form");
|
||||||
|
|
||||||
m.AddFunction(function1);
|
m.AddFunction(function1);
|
||||||
m.AddFunction(function2);
|
// If this succeeds, we'll have a double-free with the `delete` below. Avoid
|
||||||
|
// that.
|
||||||
|
ASSERT_FALSE(m.AddFunction(function2));
|
||||||
|
delete function2;
|
||||||
|
|
||||||
m.Write(s, ALL_SYMBOL_DATA);
|
m.Write(s, ALL_SYMBOL_DATA);
|
||||||
string contents = s.str();
|
string contents = s.str();
|
||||||
|
|
Loading…
Reference in a new issue