llvm.org GIT mirror llvm / 3e64427
Enhance the sanity check for block sizes; check that the resulting pointer is pointing to the range [first character, last character] instead of just not after the last character. Patch by Yan Ivnitskiy! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133867 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 9 years ago
1 changed file(s) with 4 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
374374
375375 // Check that the block wasn't partially defined, and that the offset isn't
376376 // bogus.
377 if (AtEndOfStream() || NextChar+NumWords*4 > BitStream->getLastChar())
377 const unsigned char *const SkipTo = NextChar + NumWords*4;
378 if (AtEndOfStream() || SkipTo > BitStream->getLastChar() ||
379 SkipTo < BitStream->getFirstChar())
378380 return true;
379381
380 NextChar += NumWords*4;
382 NextChar = SkipTo;
381383 return false;
382384 }
383385