[PATCH] D59051: Fix ASTReader invalid bounds check
Christy Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 6 14:07:28 PST 2019
christylee created this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
christylee added reviewers: tks2103, modocache.
The ASTReader does the index bounds check before incrementing the index, so `Clang :: Modules/module_file_info.m` failed on `include/llvm/ADT/SmallVector.h:153 assert(idx < size())`. This fixes the bounds check by incrementing first.
Repository:
rL LLVM
https://reviews.llvm.org/D59051
Files:
clang/lib/Serialization/ASTReader.cpp
Index: clang/lib/Serialization/ASTReader.cpp
===================================================================
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -4863,10 +4863,11 @@
if (!NeedsImports)
break;
- unsigned Idx = 0, N = Record.size();
- while (Idx < N) {
+ // Kind, ImportLoc, Size, ModTime, Signature
+ unsigned chunkSize = 1+1+1+1+5;
+ unsigned N = Record.size();
+ for (unsigned Idx = chunkSize; Idx < N; Idx += chunkSize) {
// Read information about the AST file.
- Idx += 1+1+1+1+5; // Kind, ImportLoc, Size, ModTime, Signature
std::string ModuleName = ReadString(Record, Idx);
std::string Filename = ReadString(Record, Idx);
ResolveImportedPath(Filename, ModuleDir);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59051.189589.patch
Type: text/x-patch
Size: 815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190306/0493873e/attachment.bin>
More information about the llvm-commits
mailing list