aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/HeaderMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Lex/HeaderMap.cpp')
-rw-r--r--clang/lib/Lex/HeaderMap.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Lex/HeaderMap.cpp b/clang/lib/Lex/HeaderMap.cpp
index 14731f29..588b32e 100644
--- a/clang/lib/Lex/HeaderMap.cpp
+++ b/clang/lib/Lex/HeaderMap.cpp
@@ -155,6 +155,10 @@ std::optional<StringRef> HeaderMapImpl::getString(unsigned StrTabIdx) const {
const char *Data = FileBuffer->getBufferStart() + StrTabIdx;
unsigned MaxLen = FileBuffer->getBufferSize() - StrTabIdx;
+
+ if (MaxLen == 0)
+ return std::nullopt;
+
unsigned Len = strnlen(Data, MaxLen);
// Check whether the buffer is null-terminated.