Ticket #5024: Don't crash upon invalid code when checking auto variables.
This commit is contained in:
parent
67915749b0
commit
d67a0add47
|
@ -101,6 +101,9 @@ static bool checkRvalueExpression(const Token * const vartok)
|
|||
|
||||
static bool variableIsUsedInScope(const Token* start, unsigned int varId, const Scope *scope)
|
||||
{
|
||||
if(!start) // Ticket #5024
|
||||
return false;
|
||||
|
||||
for (const Token *tok = start; tok != scope->classEnd; tok = tok->next()) {
|
||||
if (tok->varId() == varId)
|
||||
return true;
|
||||
|
|
|
@ -78,6 +78,7 @@ private:
|
|||
TEST_CASE(testautovar9);
|
||||
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(testautovar12); // ticket #5024 - crash
|
||||
TEST_CASE(testautovar_array1);
|
||||
TEST_CASE(testautovar_array2);
|
||||
TEST_CASE(testautovar_return1);
|
||||
|
@ -325,6 +326,10 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Address of local auto-variable assigned to a function parameter.\n", errout.str());
|
||||
}
|
||||
|
||||
void testautovar12() { // Ticket #5024 - Crash on invalid input
|
||||
check("void f(int* a) { a = }");
|
||||
}
|
||||
|
||||
void testautovar_array1() {
|
||||
check("void func1(int* arr[2])\n"
|
||||
|
|
Loading…
Reference in New Issue