From efa0310455b916ca69f1c42033254932dd3ea084 Mon Sep 17 00:00:00 2001 From: "erikchen@chromium.org" Date: Mon, 26 Jan 2015 23:19:04 +0000 Subject: [PATCH] Fix a source of memory corruption. This error was causing crashes in official Chrome Mac builds on 10.8.5 machines. BUG=chromium:449214 R=mark@chromium.org git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1414 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/dwarf_cu_to_module.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/common/dwarf_cu_to_module.cc b/src/common/dwarf_cu_to_module.cc index 444e9a94..4bd7bdd5 100644 --- a/src/common/dwarf_cu_to_module.cc +++ b/src/common/dwarf_cu_to_module.cc @@ -396,6 +396,18 @@ string DwarfCUToModule::GenericDIEHandler::ComputeQualifiedName() { enclosing_name = &parent_context_->name; } + // Prepare the return value before upcoming mutations possibly invalidate the + // existing pointers. + string return_value; + if (qualified_name) { + return_value = *qualified_name; + } else { + // Combine the enclosing name and unqualified name to produce our + // own fully-qualified name. + return_value = cu_context_->language->MakeQualifiedName(*enclosing_name, + *unqualified_name); + } + // If this DIE was marked as a declaration, record its names in the // specification table. if (declaration_) { @@ -409,13 +421,7 @@ string DwarfCUToModule::GenericDIEHandler::ComputeQualifiedName() { cu_context_->file_context->file_private_->specifications[offset_] = spec; } - if (qualified_name) - return *qualified_name; - - // Combine the enclosing name and unqualified name to produce our - // own fully-qualified name. - return cu_context_->language->MakeQualifiedName(*enclosing_name, - *unqualified_name); + return return_value; } // A handler class for DW_TAG_subprogram DIEs.