Skip to content

Commit c17f50a

Browse files
authored
Merge pull request #1921 from bnbarham/benb/cherry-pick-b89f7e8
[clang][Index] Add guard to IndexUnitReader module name reading
2 parents 9ac059c + 254c6ff commit c17f50a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/lib/Index/IndexUnitReader.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,10 @@ void IndexUnitReaderImpl::constructFilePath(SmallVectorImpl<char> &PathBuf,
378378
}
379379

380380
StringRef IndexUnitReaderImpl::getModuleName(int ModuleIndex) {
381-
if (ModuleIndex < 0)
381+
if (ModuleIndex < 0 || ModuleNamesBuffer.empty())
382382
return StringRef();
383383
auto &ModInfo = Modules[ModuleIndex];
384-
return StringRef(ModuleNamesBuffer.data()+ModInfo.NameOffset, ModInfo.NameSize);
384+
return ModuleNamesBuffer.substr(ModInfo.NameOffset, ModInfo.NameSize);
385385
}
386386

387387

0 commit comments

Comments
 (0)