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
This commit is contained in:
Saleem Abdulrasool 2014-02-19 02:56:55 +00:00
parent 43e4c52426
commit 909dce5fe2
1 changed files with 1 additions and 1 deletions

View File

@ -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;