Fixed #1587 (Crash while processing file)

This commit is contained in:
Daniel Marjamäki 2010-04-11 20:57:30 +02:00
parent b063783bc3
commit 6f74c0af5e
2 changed files with 22 additions and 0 deletions

View File

@ -921,6 +921,9 @@ void CheckBufferOverrun::checkGlobalAndLocalVariable()
{
// get type of variable
const Token *declTok = Token::findmatch(_tokenizer->tokens(), "[;{}] %type% * %varid% ;", varid);
if (!declTok)
continue;
type = declTok->next()->str();
// malloc() gets count of bytes and not count of

View File

@ -152,6 +152,8 @@ private:
TEST_CASE(terminateStrncpy2);
TEST_CASE(recursive_long_time);
TEST_CASE(crash); // Ticket #1587 - crash
TEST_CASE(executionPaths1);
}
@ -1922,6 +1924,23 @@ private:
}
// Ticket #1587 - crash
void crash()
{
check("struct struct A\n"
"{\n"
" int alloclen;\n"
"};\n"
"\n"
"void foo()\n"
"{\n"
" struct A *str;\n"
" str = malloc(4);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void epcheck(const char code[])
{