mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
VarMap stable_sort throws Invalid Comparator
Can thank Visual Studio 2019 debug build for finding this one. Only debug build runtime error but this is a legitimate violation of C++ standards. stable_sort requires a weak strict ordering yet inspection showed duplicates were ending up in the maplist. The solution is complexity-wise not ideal. But it certainly works to prevent this bug.
This commit is contained in:
parent
fa20ba3762
commit
b218cfab9d
1 changed files with 14 additions and 1 deletions
|
@ -292,6 +292,16 @@ bool RangeHint::compareRanges(const RangeHint *a,const RangeHint *b)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool RangeHint::rangesEqual(const RangeHint* a, const RangeHint* b)
|
||||
{
|
||||
if (a->sstart == b->sstart && a->size == b->size) {
|
||||
type_metatype ameta = a->type->getMetatype();
|
||||
type_metatype bmeta = b->type->getMetatype();
|
||||
return (ameta == bmeta);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// \param spc is the (stack) address space associated with this function's local variables
|
||||
/// \param fd is the function associated with these local variables
|
||||
/// \param g is the Architecture
|
||||
|
@ -783,7 +793,10 @@ void MapState::addRange(uintb st,Datatype *ct,uint4 fl,RangeHint::RangeType rt,i
|
|||
sign_extend(sst,spaceid->getAddrSize()*8-1);
|
||||
sst = (intb)AddrSpace::addressToByte(sst,spaceid->getWordSize());
|
||||
RangeHint *range = new RangeHint(st,sz,sst,ct,fl,rt,hi);
|
||||
maplist.push_back(range);
|
||||
if (std::find_if(maplist.begin(), maplist.end(), [range](RangeHint* rh) {
|
||||
return RangeHint::rangesEqual(rh, range);
|
||||
}) == maplist.end())
|
||||
maplist.push_back(range);
|
||||
#ifdef OPACTION_DEBUG
|
||||
if (debugon) {
|
||||
ostringstream s;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue