]> granicus.if.org Git - clang/commitdiff
Fix undefined behavior: reference bound to dereferenced null pointer.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 14 Aug 2012 22:37:22 +0000 (22:37 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 14 Aug 2012 22:37:22 +0000 (22:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161899 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Diagnostic.cpp

index e68950200fd036db3db15a121f0ee6fbe53a6530..2c49c2f7606b97a76968d1f8e4959cff34146e65 100644 (file)
@@ -167,8 +167,9 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
           (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) {