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); VariableUsage *temp = find(*i);
temp->_aliases.erase(var1->_name->varId()); if (temp)
temp->_aliases.erase(var1->_name->varId());
} }
// remove all aliases from var1 // remove all aliases from var1

View File

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