[PATCH] D50967: [Preamble] Fix an undefined behavior when checking an empty preamble can be reused.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 20 05:28:48 PDT 2018
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Passing nullptr to memcmp is UB.
Repository:
rC Clang
https://reviews.llvm.org/D50967
Files:
lib/Frontend/PrecompiledPreamble.cpp
Index: lib/Frontend/PrecompiledPreamble.cpp
===================================================================
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -416,6 +416,9 @@
Bounds.Size <= MainFileBuffer->getBufferSize() &&
"Buffer is too large. Bounds were calculated from a different buffer?");
+ if (Bounds.Size == 0)
+ return PreambleBytes.size() == Bounds.Size;
+
auto PreambleInvocation = std::make_shared<CompilerInvocation>(Invocation);
PreprocessorOptions &PreprocessorOpts =
PreambleInvocation->getPreprocessorOpts();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50967.161464.patch
Type: text/x-patch
Size: 601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180820/372a317d/attachment.bin>
More information about the cfe-commits
mailing list