Avoid returning points from the symbol map.

Now that it uses a lookup, this is even more dangerous.  But, the maps
could be reordered while it's trying to print the pointer and cause that
data to become invalid.

This should be safe from race conditions.
This commit is contained in:
Unknown W. Brackets committed 2014-01-25 21:40:23 -08:00
1 parent b1af4f4911
commit 76afb2a8d5
11 files changed
+69 -50

No files matched your search

+10 -3
View File
@@ -333,9 +333,7 @@ u32 SymbolMap::GetNextSymbolAddress(u32 address, SymbolType symmask) {
return dataAddress;
}
static char descriptionTemp[256];
const char *SymbolMap::GetDescription(unsigned int address) const {
std::string SymbolMap::GetDescription(unsigned int address) const {
lock_guard guard(lock_);
const char* labelName = NULL;
@@ -351,6 +349,7 @@ const char *SymbolMap::GetDescription(unsigned int address) const {
if (labelName != NULL)
return labelName;
char descriptionTemp[256];
sprintf(descriptionTemp, "(%08x)", address);
return descriptionTemp;
}
@@ -742,6 +741,14 @@ const char *SymbolMap::GetLabelNameRel(u32 relAddress, int moduleIndex) const {
return it->second.name;
}
std::string SymbolMap::GetLabelString(u32 address) const {
lock_guard guard(lock_);
const char *label = GetLabelName(address);
if (label == NULL)
return "";
return label;
}
bool SymbolMap::GetLabelValue(const char* name, u32& dest) {
lock_guard guard(lock_);
for (auto it = activeLabels.begin(); it != activeLabels.end(); it++) {