]> granicus.if.org Git - clang/commitdiff
libclang: fix a crash in clang_disposeDiagnosticSet when it is passed a NULL argument
authorDmitri Gribenko <gribozavr@gmail.com>
Wed, 12 Feb 2014 14:17:58 +0000 (14:17 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Wed, 12 Feb 2014 14:17:58 +0000 (14:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201236 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/CIndexDiagnostic.cpp

index 0c327f611a2b4c3af4308800d97555173f9392bf..d3450d5dece7c1f237c78fdf563231c166d1c64c 100644 (file)
@@ -450,9 +450,10 @@ CXString clang_getDiagnosticFixIt(CXDiagnostic Diag, unsigned FixIt,
 }
 
 void clang_disposeDiagnosticSet(CXDiagnosticSet Diags) {
-  CXDiagnosticSetImpl *D = static_cast<CXDiagnosticSetImpl*>(Diags);
-  if (D->isExternallyManaged())
-    delete D;
+  if (CXDiagnosticSetImpl *D = static_cast<CXDiagnosticSetImpl *>(Diags)) {
+    if (D->isExternallyManaged())
+      delete D;
+  }
 }
   
 CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,