array. This prevents it from walking out of bounds on the splits array.
Bug found with the existing tests by ASan and by the MSVC debug build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225069
91177308-0d34-0410-b5e6-
96231b3b80d8
<< ", " << NewSlices.back().endOffset() << "): " << *PLoad
<< "\n");
+ // See if we've handled all the splits.
+ if (Idx >= Size)
+ break;
+
// Setup the next partition.
PartOffset = Offsets.Splits[Idx];
++Idx;
- if (Idx > Size)
- break;
PartSize = (Idx < Size ? Offsets.Splits[Idx] : LoadSize) - PartOffset;
}
DEBUG(dbgs() << " of split load: " << *PLoad << "\n");
}
+ // See if we've finished all the splits.
+ if (Idx >= Size)
+ break;
+
// Setup the next partition.
PartOffset = Offsets.Splits[Idx];
++Idx;
- if (Idx > Size)
- break;
PartSize = (Idx < Size ? Offsets.Splits[Idx] : StoreSize) - PartOffset;
}