[cfe-commits] r162964 - /cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Jordan Rose jordan_rose at apple.com
Thu Aug 30 17:36:20 PDT 2012


Author: jrose
Date: Thu Aug 30 19:36:20 2012
New Revision: 162964

URL: http://llvm.org/viewvc/llvm-project?rev=162964&view=rev
Log:
[analyzer] Fix a crash in plist-html generation introduced in r162939.

Basically, do the correct thing to fix the XML generation error, rather
than making it even worse by unilaterally dereferencing a null pointer.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp?rev=162964&r1=162963&r2=162964&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Thu Aug 30 19:36:20 2012
@@ -500,21 +500,22 @@
     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.





More information about the cfe-commits mailing list