[cfe-commits] r161899 - /cfe/trunk/lib/Basic/Diagnostic.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Tue Aug 14 15:37:23 PDT 2012
Author: rsmith
Date: Tue Aug 14 17:37:22 2012
New Revision: 161899
URL: http://llvm.org/viewvc/llvm-project?rev=161899&view=rev
Log:
Fix undefined behavior: reference bound to dereferenced null pointer.
Modified:
cfe/trunk/lib/Basic/Diagnostic.cpp
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=161899&r1=161898&r2=161899&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Tue Aug 14 17:37:22 2012
@@ -167,8 +167,9 @@
(Map == diag::MAP_FATAL || Map == diag::MAP_ERROR)) &&
"Cannot map errors into warnings!");
assert(!DiagStatePoints.empty());
+ assert((L.isInvalid() || SourceMgr) && "No SourceMgr for valid location");
- FullSourceLoc Loc(L, *SourceMgr);
+ FullSourceLoc Loc = SourceMgr? FullSourceLoc(L, *SourceMgr) : FullSourceLoc();
FullSourceLoc LastStateChangePos = DiagStatePoints.back().Loc;
// Don't allow a mapping to a warning override an error/fatal mapping.
if (Map == diag::MAP_WARNING) {
More information about the cfe-commits
mailing list