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:
parent
b1af4f4911
commit
76afb2a8d5
11 changed files with 69 additions and 50 deletions
|
@ -205,8 +205,8 @@ bool CtrlDisAsmView::getDisasmAddressText(u32 address, char* dest, bool abbrevia
|
|||
{
|
||||
if (displaySymbols)
|
||||
{
|
||||
const char* addressSymbol = symbolMap.GetLabelName(address);
|
||||
if (addressSymbol != NULL)
|
||||
const std::string addressSymbol = symbolMap.GetLabelString(address);
|
||||
if (!addressSymbol.empty())
|
||||
{
|
||||
for (int k = 0; addressSymbol[k] != 0; k++)
|
||||
{
|
||||
|
@ -915,7 +915,7 @@ void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
|
|||
{
|
||||
char name[256];
|
||||
std::string newname;
|
||||
strncpy_s(name, symbolMap.GetLabelName(funcBegin),_TRUNCATE);
|
||||
strncpy_s(name, symbolMap.GetLabelString(funcBegin).c_str(),_TRUNCATE);
|
||||
if (InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), L"New function name", name, newname)) {
|
||||
symbolMap.SetLabelName(newname.c_str(),funcBegin);
|
||||
u32 funcSize = symbolMap.GetFunctionSize(curAddress);
|
||||
|
@ -1048,10 +1048,10 @@ void CtrlDisAsmView::updateStatusBarText()
|
|||
// TODO: Could also be a float...
|
||||
{
|
||||
u32 data = Memory::Read_U32(line.info.dataAddress);
|
||||
const char* addressSymbol = symbolMap.GetLabelName(data);
|
||||
if (addressSymbol)
|
||||
const std::string addressSymbol = symbolMap.GetLabelString(data);
|
||||
if (!addressSymbol.empty())
|
||||
{
|
||||
sprintf(text,"[%08X] = %s (%08X)",line.info.dataAddress,addressSymbol,data);
|
||||
sprintf(text,"[%08X] = %s (%08X)",line.info.dataAddress,addressSymbol.c_str(),data);
|
||||
} else {
|
||||
sprintf(text,"[%08X] = %08X",line.info.dataAddress,data);
|
||||
}
|
||||
|
@ -1066,12 +1066,12 @@ void CtrlDisAsmView::updateStatusBarText()
|
|||
|
||||
if (line.info.isBranch)
|
||||
{
|
||||
const char* addressSymbol = symbolMap.GetLabelName(line.info.branchTarget);
|
||||
if (addressSymbol == NULL)
|
||||
const std::string addressSymbol = symbolMap.GetLabelString(line.info.branchTarget);
|
||||
if (addressSymbol.empty())
|
||||
{
|
||||
sprintf(text,"%08X",line.info.branchTarget);
|
||||
} else {
|
||||
sprintf(text,"%08X = %s",line.info.branchTarget,addressSymbol);
|
||||
sprintf(text,"%08X = %s",line.info.branchTarget,addressSymbol.c_str());
|
||||
}
|
||||
}
|
||||
} else if (line.type == DISTYPE_DATA)
|
||||
|
@ -1081,14 +1081,14 @@ void CtrlDisAsmView::updateStatusBarText()
|
|||
start = curAddress;
|
||||
|
||||
u32 diff = curAddress-start;
|
||||
const char* label = symbolMap.GetLabelName(start);
|
||||
const std::string label = symbolMap.GetLabelString(start);
|
||||
|
||||
if (label != NULL)
|
||||
if (!label.empty())
|
||||
{
|
||||
if (diff != 0)
|
||||
sprintf(text,"%08X (%s) + %08X",start,label,diff);
|
||||
sprintf(text,"%08X (%s) + %08X",start,label.c_str(),diff);
|
||||
else
|
||||
sprintf(text,"%08X (%s)",start,label);
|
||||
sprintf(text,"%08X (%s)",start,label.c_str());
|
||||
} else {
|
||||
if (diff != 0)
|
||||
sprintf(text,"%08X + %08X",start,diff);
|
||||
|
@ -1204,7 +1204,7 @@ std::string CtrlDisAsmView::disassembleRange(u32 start, u32 size)
|
|||
{
|
||||
MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(debugger,start+i);
|
||||
|
||||
if (info.isBranch && symbolMap.GetLabelName(info.branchTarget) == NULL)
|
||||
if (info.isBranch && symbolMap.GetLabelString(info.branchTarget).empty())
|
||||
{
|
||||
if (branchAddresses.find(info.branchTarget) == branchAddresses.end())
|
||||
{
|
||||
|
@ -1236,7 +1236,7 @@ std::string CtrlDisAsmView::disassembleRange(u32 start, u32 size)
|
|||
}
|
||||
|
||||
if (line.info.isBranch && !line.info.isBranchToRegister
|
||||
&& symbolMap.GetLabelName(line.info.branchTarget) == NULL
|
||||
&& symbolMap.GetLabelString(line.info.branchTarget).empty()
|
||||
&& branchAddresses.find(line.info.branchTarget) != branchAddresses.end())
|
||||
{
|
||||
sprintf(buffer,"pos_%08X",line.info.branchTarget);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue