Fixed #5537 (crash: clang ./lib/Basic/FileManager.cpp , since 354e84e7c8 , /lib/symboldatabase.h:288)

This commit is contained in:
Alexander Mai 2014-03-09 08:17:24 +01:00 committed by Daniel Marjamäki
parent 2ac2dcf392
commit 3f30753122
2 changed files with 12 additions and 1 deletions

View File

@ -202,7 +202,7 @@ void CheckAutoVariables::autoVariables()
errorInvalidDeallocation(tok); errorInvalidDeallocation(tok);
} else if (Token::Match(tok, "free ( & %var% ) ;") || Token::Match(tok, "delete [| ]| (| & %var% !![")) { } else if (Token::Match(tok, "free ( & %var% ) ;") || Token::Match(tok, "delete [| ]| (| & %var% !![")) {
tok = Token::findmatch(tok->next(), "%var%"); tok = Token::findmatch(tok->next(), "%var%");
if (tok->variable()->isLocal()) if (tok && tok->variable() && tok->variable()->isLocal())
errorInvalidDeallocation(tok); errorInvalidDeallocation(tok);
} }
} }

View File

@ -80,6 +80,7 @@ private:
TEST_CASE(testautovar10); // ticket #2930 - void f(char *p) { p = '\0'; } TEST_CASE(testautovar10); // ticket #2930 - void f(char *p) { p = '\0'; }
TEST_CASE(testautovar11); // ticket #4641 - fp, assign local struct member address to function parameter TEST_CASE(testautovar11); // ticket #4641 - fp, assign local struct member address to function parameter
TEST_CASE(testautovar12); // ticket #5024 - crash TEST_CASE(testautovar12); // ticket #5024 - crash
TEST_CASE(testautovar13); // ticket #5537 - crash
TEST_CASE(testautovar_array1); TEST_CASE(testautovar_array1);
TEST_CASE(testautovar_array2); TEST_CASE(testautovar_array2);
TEST_CASE(testautovar_return1); TEST_CASE(testautovar_return1);
@ -359,6 +360,16 @@ private:
"UNKNOWN_MACRO_EXPANDING_TO_SIGNATURE { custom_type a(var); }"); "UNKNOWN_MACRO_EXPANDING_TO_SIGNATURE { custom_type a(var); }");
} }
void testautovar13() { // Ticket #5537
check("class FileManager {\n"
" FileManager() : UniqueRealDirs(*new UniqueDirContainer())\n"
" {}\n"
" ~FileManager() {\n"
" delete &UniqueRealDirs;\n"
" }\n"
"};\n");
}
void testautovar_array1() { void testautovar_array1() {
check("void func1(int* arr[2])\n" check("void func1(int* arr[2])\n"
"{\n" "{\n"