Fixed #1720 (segmentation fault of cppcheck)

This commit is contained in:
Daniel Marjamäki 2010-06-02 18:10:32 +02:00
parent 5789eb116d
commit cb43168d81
2 changed files with 15 additions and 15 deletions

View File

@ -523,7 +523,8 @@ void Variables::alias(unsigned int varid1, unsigned int varid2)
{
VariableUsage *temp = find(*i);
temp->_aliases.erase(var1->_name->varId());
if (temp)
temp->_aliases.erase(var1->_name->varId());
}
// remove all aliases from var1

View File

@ -1147,20 +1147,19 @@ private:
void localvar17() // ticket #1720
{
// FIXME: Don't crash when checking the code below!
/*
functionVariableUsage("void foo()\n"
"{\n"
" struct DATA *data;\n"
" char *k = data->req;\n"
" char *ptr;\n"
" char *line_start;\n"
" ptr = data->buffer;\n"
" line_start = ptr;\n"
" data->info = k;\n"
" line_start = ptr;\n"
"}\n");
*/
// Don't crash when checking the code below!
functionVariableUsage("void foo()\n"
"{\n"
" struct DATA *data;\n"
" char *k = data->req;\n"
" char *ptr;\n"
" char *line_start;\n"
" ptr = data->buffer;\n"
" line_start = ptr;\n"
" data->info = k;\n"
" line_start = ptr;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:6]: (style) Variable 'line_start' is assigned a value that is never used\n", errout.str());
}
void localvaralias1()