From 56e7a3c65df2a89cd35ee13800284dc29fb90aad Mon Sep 17 00:00:00 2001 From: jimblandy Date: Wed, 28 Apr 2010 18:16:00 +0000 Subject: 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 --- src/common/dump_stabs.cc | 9 +++++++++ src/common/dump_stabs.h | 1 + 2 files changed, 10 insertions(+) (limited to 'src/common') diff --git a/src/common/dump_stabs.cc b/src/common/dump_stabs.cc index 436b6215..e4ae1e1b 100644 --- a/src/common/dump_stabs.cc +++ b/src/common/dump_stabs.cc @@ -56,6 +56,15 @@ static string Demangle(const string &mangled) { return string(mangled); } +DumpStabsHandler::~DumpStabsHandler() { + // Free any functions we've accumulated but not added to the module. + for (vector::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, const char *build_directory) { assert(!in_compilation_unit_); diff --git a/src/common/dump_stabs.h b/src/common/dump_stabs.h index e5c34409..36d773e8 100644 --- a/src/common/dump_stabs.h +++ b/src/common/dump_stabs.h @@ -68,6 +68,7 @@ class DumpStabsHandler: public google_breakpad::StabsHandler { current_function_(NULL), current_source_file_(NULL), current_source_file_name_(NULL) { } + ~DumpStabsHandler(); // The standard StabsHandler virtual member functions. bool StartCompilationUnit(const char *name, uint64_t address, -- cgit v1.2.1