mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2025-12-28 10:15:10 +01:00
Fix some fragile code that is likely to cause future memory corruption
problems. - The ordering of keys in stl containers cannot change. Make the relevant members const to guarantee this assumption. - Add handling and logging for demangle errors. - Fix a potential double-delete bug if a function passed to AddFunction() is already present. BUG=chromium:449214 R=mark@chromium.org Review URL: https://breakpad.appspot.com/10704002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1415 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
efa0310455
commit
7bebb27fb4
8 changed files with 62 additions and 58 deletions
|
|
@ -80,7 +80,7 @@ void Module::AddFunction(Function *function) {
|
|||
// callers try to add one.
|
||||
assert(!function->name.empty());
|
||||
std::pair<FunctionSet::iterator,bool> ret = functions_.insert(function);
|
||||
if (!ret.second) {
|
||||
if (!ret.second && (*ret.first != function)) {
|
||||
// Free the duplicate that was not inserted because this Module
|
||||
// now owns it.
|
||||
delete function;
|
||||
|
|
@ -98,9 +98,7 @@ void Module::AddStackFrameEntry(StackFrameEntry *stack_frame_entry) {
|
|||
}
|
||||
|
||||
void Module::AddExtern(Extern *ext) {
|
||||
Function func;
|
||||
func.name = ext->name;
|
||||
func.address = ext->address;
|
||||
Function func(ext->name, ext->address);
|
||||
|
||||
// Since parsing debug section and public info are not necessarily
|
||||
// mutually exclusive, check if the symbol has already been read
|
||||
|
|
@ -141,8 +139,7 @@ Module::File *Module::FindFile(const string &name) {
|
|||
FileByNameMap::iterator destiny = files_.lower_bound(&name);
|
||||
if (destiny == files_.end()
|
||||
|| *destiny->first != name) { // Repeated string comparison, boo hoo.
|
||||
File *file = new File;
|
||||
file->name = name;
|
||||
File *file = new File(name);
|
||||
file->source_id = -1;
|
||||
destiny = files_.insert(destiny,
|
||||
FileByNameMap::value_type(&file->name, file));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue