Remove footguns from a few APIs
This commit is contained in:
parent
6c3d3941cb
commit
09bc3aed4f
|
|
@ -127,6 +127,10 @@ static void _getsehchain(DBGSEHCHAIN* sehchain)
|
|||
MemRead(SEHList[i] + 4, &sehchain->records[i].handler, sizeof(duint));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sehchain->records = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static bool _getjitauto(bool* jit_auto)
|
||||
|
|
@ -183,7 +187,10 @@ static bool _getprocesslist(DBGPROCESSINFO** entries, int* count)
|
|||
return false;
|
||||
*count = (int)infoList.size();
|
||||
if(!*count)
|
||||
{
|
||||
*entries = nullptr;
|
||||
return false;
|
||||
}
|
||||
*entries = (DBGPROCESSINFO*)BridgeAlloc(*count * sizeof(DBGPROCESSINFO));
|
||||
for(int i = 0; i < *count; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ extern "C" DLL_EXPORT bool _dbg_memmap(MEMMAP* memmap)
|
|||
SHARED_ACQUIRE(LockMemoryPages);
|
||||
|
||||
int pagecount = (int)memoryPages.size();
|
||||
memset(memmap, 0, sizeof(MEMMAP));
|
||||
memmap->count = pagecount;
|
||||
memmap->page = nullptr;
|
||||
if(!pagecount)
|
||||
return true;
|
||||
|
||||
|
|
@ -802,13 +802,14 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
|
|||
{
|
||||
if(!bpmap)
|
||||
return 0;
|
||||
|
||||
bpmap->count = 0;
|
||||
bpmap->bp = nullptr;
|
||||
|
||||
std::vector<BREAKPOINT> list;
|
||||
int bpcount = BpGetList(&list);
|
||||
if(bpcount == 0)
|
||||
{
|
||||
bpmap->count = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int retcount = 0;
|
||||
std::vector<BRIDGEBP> bridgeList;
|
||||
|
|
@ -847,10 +848,7 @@ extern "C" DLL_EXPORT int _dbg_getbplist(BPXTYPE type, BPMAP* bpmap)
|
|||
retcount++;
|
||||
}
|
||||
if(!retcount)
|
||||
{
|
||||
bpmap->count = retcount;
|
||||
return retcount;
|
||||
}
|
||||
return 0;
|
||||
bpmap->count = retcount;
|
||||
bpmap->bp = (BRIDGEBP*)BridgeAlloc(sizeof(BRIDGEBP) * retcount);
|
||||
for(int i = 0; i < retcount; i++)
|
||||
|
|
@ -1395,6 +1393,7 @@ extern "C" DLL_EXPORT duint _dbg_sendmessage(DBGMSG type, void* param1, void* pa
|
|||
|
||||
if(info->refcount == 0)
|
||||
{
|
||||
info->references = nullptr;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -452,6 +452,10 @@ void stackgetcallstackbythread(HANDLE thread, CALLSTACK* callstack)
|
|||
// Copy data directly from the vector
|
||||
memcpy(callstack->entries, callstackVector.data(), callstack->total * sizeof(CALLSTACKENTRY));
|
||||
}
|
||||
else
|
||||
{
|
||||
callstack->entries = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void stackgetcallstack(duint csp, CALLSTACK* callstack)
|
||||
|
|
@ -469,6 +473,10 @@ void stackgetcallstack(duint csp, CALLSTACK* callstack)
|
|||
// Copy data directly from the vector
|
||||
memcpy(callstack->entries, callstackVector.data(), callstack->total * sizeof(CALLSTACKENTRY));
|
||||
}
|
||||
else
|
||||
{
|
||||
callstack->entries = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void stackupdatesettings()
|
||||
|
|
|
|||
|
|
@ -101,10 +101,12 @@ void ThreadGetList(THREADLIST* List)
|
|||
// Also assume BridgeAlloc zeros the returned buffer.
|
||||
//
|
||||
List->count = (int)threadList.size();
|
||||
List->list = nullptr;
|
||||
|
||||
if(List->count <= 0)
|
||||
if(List->count == 0)
|
||||
{
|
||||
List->list = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate C-style array
|
||||
List->list = (THREADALLINFO*)BridgeAlloc(List->count * sizeof(THREADALLINFO));
|
||||
|
|
|
|||
Loading…
Reference in New Issue