From 371c217b3f47c8e06dfbc7a86882e60d5059bba9 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Wed, 12 Feb 2014 14:17:58 +0000 Subject: [PATCH] libclang: fix a crash in clang_disposeDiagnosticSet when it is passed a NULL argument llvm-svn: 201236 --- clang/tools/libclang/CIndexDiagnostic.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/tools/libclang/CIndexDiagnostic.cpp b/clang/tools/libclang/CIndexDiagnostic.cpp index 0c327f611a2b..d3450d5dece7 100644 --- a/clang/tools/libclang/CIndexDiagnostic.cpp +++ b/clang/tools/libclang/CIndexDiagnostic.cpp @@ -450,9 +450,10 @@ CXString clang_getDiagnosticFixIt(CXDiagnostic Diag, unsigned FixIt, } void clang_disposeDiagnosticSet(CXDiagnosticSet Diags) { - CXDiagnosticSetImpl *D = static_cast(Diags); - if (D->isExternallyManaged()) - delete D; + if (CXDiagnosticSetImpl *D = static_cast(Diags)) { + if (D->isExternallyManaged()) + delete D; + } } CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags,