1
0
Fork 0

DBG+GUI: fixed various bugs found by coverity

This commit is contained in:
Mr. eXoDia 2015-07-11 05:18:06 +02:00
parent c86eaa5a08
commit 047e45b44e
6 changed files with 13 additions and 8 deletions

View File

@ -96,8 +96,7 @@ static const char* regTable[] =
SCRIPT_EXPORT duint Script::Register::Get(Script::Register::RegisterEnum reg)
{
duint value;
valfromstring(regTable[reg], &value);
return value;
return valfromstring(regTable[reg], &value) ? value : 0;
}
SCRIPT_EXPORT bool Script::Register::Set(Script::Register::RegisterEnum reg, duint value)

View File

@ -71,8 +71,10 @@ void FunctionAnalysis::AnalyseFunctions()
uint end = FindFunctionEnd(function.start, maxaddr);
if(end)
{
_cp.Disassemble(end, TranslateAddress(end), MAX_DISASM_BUFFER);
function.end = end + _cp.Size() - 1;
if(_cp.Disassemble(end, TranslateAddress(end), MAX_DISASM_BUFFER))
function.end = end + _cp.Size() - 1;
else
function.end = end;
}
}
}

View File

@ -1511,7 +1511,7 @@ static bool cbFindAsm(Capstone* disasm, BASIC_INSTRUCTION_INFO* basicinfo, REFIN
if(found)
{
char addrText[20] = "";
sprintf(addrText, "%p", disasm->Address());
sprintf(addrText, fhex, disasm->Address());
GuiReferenceSetRowCount(refinfo->refcount + 1);
GuiReferenceSetCellContent(refinfo->refcount, 0, addrText);
char disassembly[GUI_MAX_DISASSEMBLY_SIZE] = "";

View File

@ -8,6 +8,7 @@ StdTable::StdTable(QWidget* parent) : AbstractTableView(parent)
mSelection = data;
mIsMultiSelctionAllowed = false;
mIsColumnSortingAllowed = true;
mData.clear();
mSort.first = -1;

View File

@ -483,7 +483,8 @@ QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i
int_t wRva = (rowBase + rowOffset) * getBytePerRowCount() - mByteOffset;
mMemPage->read((byte_t*)&data, wRva, sizeof(uint_t));
char modname[MAX_MODULE_SIZE] = "";
DbgGetModuleAt(data, modname);
if(!DbgGetModuleAt(data, modname))
modname[0] = '\0';
char label_text[MAX_LABEL_SIZE] = "";
if(DbgGetLabelAt(data, SEG_DEFAULT, label_text))
wStr = QString(modname) + "." + QString(label_text);

View File

@ -559,9 +559,11 @@ void PatchDialog::on_btnImport_clicked()
unsigned char checkbyte = 0;
DbgMemRead(curPatch.addr, &checkbyte, sizeof(checkbyte));
IMPORTSTATUS status;
if(status.alreadypatched = checkbyte == newbyte)
status.alreadypatched = (checkbyte == newbyte);
status.badoriginal = (checkbyte != oldbyte);
if(status.alreadypatched)
bAlreadyDone = true;
else if(status.badoriginal = checkbyte != oldbyte)
else if(status.badoriginal)
bBadOriginal = true;
curPatch.oldbyte = oldbyte;
curPatch.newbyte = newbyte;