[lldb-test] ir-memory-map: Avoid accessing a bad iterator

Do not access Probe.start() when Probe is at the end of the interval
map.

llvm-svn: 333585
This commit is contained in:
Vedant Kumar 2018-05-30 19:46:47 +00:00
parent b6423479a1
commit f3b6d2930d
1 changed files with 8 additions and 10 deletions

View File

@ -551,17 +551,15 @@ bool opts::irmemorymap::evalMalloc(IRMemoryMap &IRMemMap, StringRef Line,
auto Probe = AllocatedIntervals.begin();
Probe.advanceTo(Addr); //< First interval s.t stop >= Addr.
AllocationT NewAllocation = {Addr, EndOfRegion};
if (Probe != AllocatedIntervals.end()) {
while (Probe.start() < EndOfRegion) {
AllocationT ProbeAllocation = {Probe.start(), Probe.stop()};
if (areAllocationsOverlapping(ProbeAllocation, NewAllocation)) {
outs() << "Malloc error: overlapping allocation detected"
<< formatv(", previous allocation at [{0:x}, {1:x})\n",
Probe.start(), Probe.stop());
exit(1);
}
++Probe;
while (Probe != AllocatedIntervals.end() && Probe.start() < EndOfRegion) {
AllocationT ProbeAllocation = {Probe.start(), Probe.stop()};
if (areAllocationsOverlapping(ProbeAllocation, NewAllocation)) {
outs() << "Malloc error: overlapping allocation detected"
<< formatv(", previous allocation at [{0:x}, {1:x})\n",
Probe.start(), Probe.stop());
exit(1);
}
++Probe;
}
// Insert the new allocation into the interval map.