From 909dce5fe2afed6d7bcc58feda717ae065220cef Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 19 Feb 2014 02:56:55 +0000 Subject: [PATCH] CIndex: initialise TU TU is not guaranteed to be initialised in all cases. In particular if CIdx or ast_filename is NULL (or if &TU is NULL), then clang_createTranslationUnit2 will not initialise the out parameter out_TU. This is followed by an assertion check which may perform a branch based on unitialised memory. Caught by scan-build. llvm-svn: 201628 --- clang/tools/libclang/CIndex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index e862889f2636..c5f41a8a7422 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -2612,7 +2612,7 @@ void clang_toggleCrashRecovery(unsigned isEnabled) { CXTranslationUnit clang_createTranslationUnit(CXIndex CIdx, const char *ast_filename) { - CXTranslationUnit TU; + CXTranslationUnit TU = NULL; enum CXErrorCode Result = clang_createTranslationUnit2(CIdx, ast_filename, &TU); (void)Result;