#6705 segmentation fault (invalid code) in CheckVaarg::va_list_usage. Local fix i nchecker preventing SIGSEGV on NULL-token
This commit is contained in:
parent
0bd7cbfbeb
commit
e498f8493e
|
@ -92,7 +92,7 @@ void CheckVaarg::va_list_usage()
|
||||||
bool exitOnEndOfStatement = false;
|
bool exitOnEndOfStatement = false;
|
||||||
|
|
||||||
const Token* tok = var->nameToken()->next();
|
const Token* tok = var->nameToken()->next();
|
||||||
for (; tok != var->scope()->classEnd; tok = tok->next()) {
|
for (; tok && tok != var->scope()->classEnd; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "va_start ( %varid%", var->declarationId())) {
|
if (Token::Match(tok, "va_start ( %varid%", var->declarationId())) {
|
||||||
if (open)
|
if (open)
|
||||||
va_start_subsequentCallsError(tok, var->name());
|
va_start_subsequentCallsError(tok, var->name());
|
||||||
|
|
|
@ -84,6 +84,7 @@ private:
|
||||||
TEST_CASE(garbageCode43); // #6703
|
TEST_CASE(garbageCode43); // #6703
|
||||||
TEST_CASE(garbageCode44); // #6704
|
TEST_CASE(garbageCode44); // #6704
|
||||||
TEST_CASE(garbageCode45); // #6608
|
TEST_CASE(garbageCode45); // #6608
|
||||||
|
TEST_CASE(garbageCode46); // #6705
|
||||||
|
|
||||||
TEST_CASE(garbageValueFlow);
|
TEST_CASE(garbageValueFlow);
|
||||||
TEST_CASE(garbageSymbolDatabase);
|
TEST_CASE(garbageSymbolDatabase);
|
||||||
|
@ -485,6 +486,10 @@ private:
|
||||||
checkCode("struct true template < > { = } > struct Types \"s\" ; static_assert < int > ;");
|
checkCode("struct true template < > { = } > struct Types \"s\" ; static_assert < int > ;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void garbageCode46() { // #6705
|
||||||
|
checkCode(" { bar(char *x); void foo (int ...) { struct } va_list ap; va_start(ap, size); va_arg(ap, (d)); }");
|
||||||
|
}
|
||||||
|
|
||||||
void garbageValueFlow() {
|
void garbageValueFlow() {
|
||||||
// #6089
|
// #6089
|
||||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||||
|
|
Loading…
Reference in New Issue