Breakpad Linux Dumper: Have DumpStabsHandler free accumulated functions if Finalize is not called

The DumpStabsHandler class creates Module::Function objects as it processes
data from the StabsReader, but waits to add the Functions to the Module
until all parsing is complete and its Finalize member function is called,
so that it can compute line and function end addresses that the STABS data
may have left implicit.

If the DumpStabsHandler is destructed before its Finalize method is called,
it fails to free the Functions it has created, but not yet added to the
Module. (Adding a Function to a Module transfers ownership of the Function
to the Module.)

This adds a destructor to DumpStabsHandler which takes care of freeing any
Functions that it still owns.

a=jimblandy, r=thestig


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@576 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
jimblandy 2010-04-28 18:16:00 +00:00
parent 504280af60
commit 56e7a3c65d
2 changed files with 10 additions and 0 deletions

View File

@ -56,6 +56,15 @@ static string Demangle(const string &mangled) {
return string(mangled); return string(mangled);
} }
DumpStabsHandler::~DumpStabsHandler() {
// Free any functions we've accumulated but not added to the module.
for (vector<Module::Function *>::iterator func_it = functions_.begin();
func_it != functions_.end(); func_it++)
delete *func_it;
// Free any function that we're currently within.
delete current_function_;
}
bool DumpStabsHandler::StartCompilationUnit(const char *name, uint64_t address, bool DumpStabsHandler::StartCompilationUnit(const char *name, uint64_t address,
const char *build_directory) { const char *build_directory) {
assert(!in_compilation_unit_); assert(!in_compilation_unit_);

View File

@ -68,6 +68,7 @@ class DumpStabsHandler: public google_breakpad::StabsHandler {
current_function_(NULL), current_function_(NULL),
current_source_file_(NULL), current_source_file_(NULL),
current_source_file_name_(NULL) { } current_source_file_name_(NULL) { }
~DumpStabsHandler();
// The standard StabsHandler virtual member functions. // The standard StabsHandler virtual member functions.
bool StartCompilationUnit(const char *name, uint64_t address, bool StartCompilationUnit(const char *name, uint64_t address,