CheckVaarg::va_list_usage(): Bailout on "goto" (#8043)

This commit is contained in:
PKEuS 2017-05-07 08:32:48 +02:00
parent b345c430fe
commit 28b8bc57a8
2 changed files with 16 additions and 1 deletions

View File

@ -132,7 +132,7 @@ void CheckVaarg::va_list_usage()
tok = scope->classEnd;
if (!tok)
return;
} else if (_tokenizer->isCPP() && tok->str() == "try") {
} else if (tok->str() == "goto" || (_tokenizer->isCPP() && tok->str() == "try")) {
open = false;
break;
} else if (!open && tok->varId() == var->declarationId())

View File

@ -263,6 +263,21 @@ private:
" }\n"
"}");
ASSERT_EQUALS("[test.cpp:13]: (error) va_list 'args' was opened but not closed by va_end().\n", errout.str());
// #8043
check("void redisvFormatCommand(char *format, va_list ap, bool flag) {\n"
" va_list _cpy;\n"
" va_copy(_cpy, ap);\n"
" if (flag)\n"
" goto fmt_valid;\n"
" va_end(_cpy);\n"
" goto format_err;\n"
"fmt_valid:\n"
" sdscatvprintf(curarg, _format, _cpy);\n"
" va_end(_cpy);\n"
"format_err:\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void va_start_subsequentCalls() {