Fixed #1720 (segmentation fault of cppcheck)
This commit is contained in:
parent
5789eb116d
commit
cb43168d81
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue