]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix a crash in plist-html generation introduced in r162939.
authorJordan Rose <jordan_rose@apple.com>
Fri, 31 Aug 2012 00:36:20 +0000 (00:36 +0000)
committerJordan Rose <jordan_rose@apple.com>
Fri, 31 Aug 2012 00:36:20 +0000 (00:36 +0000)
Basically, do the correct thing to fix the XML generation error, rather
than making it even worse by unilaterally dereferencing a null pointer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162964 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

index c038b632e9aa2c9c5ff6f6c7d9aa0ae1db0efbbb..c1c46c293a78a47469be9acfce164309b3972a27 100644 (file)
@@ -500,21 +500,22 @@ void PlistDiagnostics::FlushDiagnosticsImpl(
     if (!filesMade->empty()) {
       StringRef lastName;
       PDFileEntry::ConsumerFiles *files = filesMade->getFiles(*D);
-      for (PDFileEntry::ConsumerFiles::const_iterator CI = files->begin(),
-              CE = files->end(); CI != CE; ++CI) {
-        StringRef newName = CI->first;
-        if (newName != lastName) {
-          if (!lastName.empty()) {
-            o << "  </array>\n";
+      if (files) {
+        for (PDFileEntry::ConsumerFiles::const_iterator CI = files->begin(),
+                CE = files->end(); CI != CE; ++CI) {
+          StringRef newName = CI->first;
+          if (newName != lastName) {
+            if (!lastName.empty()) {
+              o << "  </array>\n";
+            }
+            lastName = newName;
+            o <<  "  <key>" << lastName << "_files</key>\n";
+            o << "  <array>\n";
           }
-          lastName = newName;
-          o <<  "  <key>" << lastName << "_files</key>\n";
-          o << "  <array>\n";
+          o << "   <string>" << CI->second << "</string>\n";
         }
-        o << "   <string>" << CI->second << "</string>\n";
-      }
-      if (!lastName.empty())
         o << "  </array>\n";
+      }
     }
 
     // Close up the entry.