Fixed #2621 (Segmentation fault for GCC statement expression)
This commit is contained in:
parent
384729204f
commit
f26bc6a75c
|
@ -635,7 +635,10 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
|
||||||
null = false;
|
null = false;
|
||||||
|
|
||||||
// start token = first token after the if/while body
|
// start token = first token after the if/while body
|
||||||
tok1 = tok1->previous()->link()->next();
|
tok1 = tok1->previous()->link();
|
||||||
|
tok1 = tok1 ? tok1->next() : NULL;
|
||||||
|
if (!tok1)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name of the pointer
|
// Name of the pointer
|
||||||
|
|
|
@ -46,6 +46,7 @@ private:
|
||||||
TEST_CASE(nullpointer9);
|
TEST_CASE(nullpointer9);
|
||||||
TEST_CASE(pointerCheckAndDeRef); // check if pointer is null and then dereference it
|
TEST_CASE(pointerCheckAndDeRef); // check if pointer is null and then dereference it
|
||||||
TEST_CASE(nullConstantDereference); // Dereference NULL constant
|
TEST_CASE(nullConstantDereference); // Dereference NULL constant
|
||||||
|
TEST_CASE(gcc_statement_expression); // Don't crash
|
||||||
}
|
}
|
||||||
|
|
||||||
void check(const char code[])
|
void check(const char code[])
|
||||||
|
@ -1003,6 +1004,14 @@ private:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gcc_statement_expression()
|
||||||
|
{
|
||||||
|
// Ticket #2621
|
||||||
|
check("void f(struct ABC *abc) {\n"
|
||||||
|
" ({ if (abc) dbg(); })\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestNullPointer)
|
REGISTER_TEST(TestNullPointer)
|
||||||
|
|
Loading…
Reference in New Issue