diff options
author | erikchen@chromium.org <erikchen@chromium.org> | 2015-01-27 01:20:59 +0000 |
---|---|---|
committer | erikchen@chromium.org <erikchen@chromium.org> | 2015-01-27 01:20:59 +0000 |
commit | 7bebb27fb44920f189310985d96ed7801f59afbb (patch) | |
tree | 4488552decfc8604e6d4609ba5d56c81baa1e863 /src/common/module.h | |
parent | Fix a source of memory corruption. (diff) | |
download | breakpad-7bebb27fb44920f189310985d96ed7801f59afbb.tar.xz |
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
Diffstat (limited to 'src/common/module.h')
-rw-r--r-- | src/common/module.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/common/module.h b/src/common/module.h index 440298f0..65b5595d 100644 --- a/src/common/module.h +++ b/src/common/module.h @@ -74,8 +74,10 @@ class Module { // A source file. struct File { + explicit File(const string &name_input) : name(name_input), source_id(0) {} + // The name of the source file. - string name; + const string name; // The file's source id. The Write member function clears this // field and assigns source ids a fresh, so any value placed here @@ -85,6 +87,9 @@ class Module { // A function. struct Function { + Function(const string &name_input, const Address &address_input) : + name(name_input), address(address_input), size(0), parameter_size(0) {} + // For sorting by address. (Not style-guide compliant, but it's // stupid not to put this in the struct.) static bool CompareByAddress(const Function *x, const Function *y) { @@ -92,10 +97,11 @@ class Module { } // The function's name. - string name; + const string name; // The start address and length of the function's code. - Address address, size; + const Address address; + Address size; // The function's parameter size. Address parameter_size; @@ -120,7 +126,8 @@ class Module { // An exported symbol. struct Extern { - Address address; + explicit Extern(const Address &address_input) : address(address_input) {} + const Address address; string name; }; |