File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -279,21 +279,24 @@ static bool fillRanges(MemoryBuffer *Code,
279
279
280
280
if (Offsets.empty ())
281
281
Offsets.push_back (0 );
282
- if (Offsets.size () == 1 && Lengths.empty ()) {
283
- Lengths.push_back (Sources.getFileOffset (Sources.getLocForEndOfFile (ID)) -
284
- Offsets[0 ]);
282
+ const bool EmptyLengths = Lengths.empty ();
283
+ unsigned Length = 0 ;
284
+ if (Offsets.size () == 1 && EmptyLengths) {
285
+ Length = Sources.getFileOffset (Sources.getLocForEndOfFile (ID)) - Offsets[0 ];
285
286
} else if (Offsets.size () != Lengths.size ()) {
286
287
errs () << " error: number of -offset and -length arguments must match.\n " ;
287
288
return true ;
288
289
}
289
- for (unsigned I = 0 , E = Offsets.size (); I < E; ++I) {
290
+ for (unsigned I = 0 , E = Offsets.size (), CodeSize = Code->getBufferSize ();
291
+ I < E; ++I) {
290
292
const auto Offset = Offsets[I];
291
- if (Offset >= Code-> getBufferSize () ) {
293
+ if (Offset >= CodeSize ) {
292
294
errs () << " error: offset " << Offset << " is outside the file\n " ;
293
295
return true ;
294
296
}
295
- const auto Length = Lengths[I];
296
- if (Offset + Length > Code->getBufferSize ()) {
297
+ if (!EmptyLengths)
298
+ Length = Lengths[I];
299
+ if (Offset + Length > CodeSize) {
297
300
errs () << " error: invalid length " << Length << " , offset + length ("
298
301
<< Offset + Length << " ) is outside the file.\n " ;
299
302
return true ;
You can’t perform that action at this time.
0 commit comments