stabs_to_module: fix memory leak

Everything in `functions_` is owned by the current `StabsToModule`. If
we fail to add something from `functions_`, we need to be sure to
dispose of it properly, since `module_` will not take ownership.

Bug: b:235999011
Change-Id: I3b965709ea2016a065b50588f4132d14a1de7725
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3756733
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
George Burgess IV 2022-07-11 15:23:41 -07:00 committed by George Burgess
parent 9a1941fab9
commit 4b7984b351

View file

@ -192,9 +192,11 @@ void StabsToModule::Finalize() {
} }
} }
// Now that everything has a size, add our functions to the module, and // Now that everything has a size, add our functions to the module, and
// dispose of our private list. // dispose of our private list. Delete the functions that we fail to add, so
// they aren't leaked.
for (Module::Function* func: functions_) for (Module::Function* func: functions_)
module_->AddFunction(func); if (!module_->AddFunction(func))
delete func;
functions_.clear(); functions_.clear();
} }