CheckVaarg::va_list_usage(): Bailout when try{} block is encountered (#6186)
This commit is contained in:
parent
21c85118d6
commit
812bc6bdaf
|
@ -114,7 +114,10 @@ void CheckVaarg::va_list_usage()
|
||||||
tok = tok->linkAt(1);
|
tok = tok->linkAt(1);
|
||||||
} else if (Token::Match(tok, "throw|return"))
|
} else if (Token::Match(tok, "throw|return"))
|
||||||
exitOnEndOfStatement = true;
|
exitOnEndOfStatement = true;
|
||||||
else if (!open && tok->varId() == var->declarationId())
|
else if (_tokenizer->isCPP() && tok->str() == "try") {
|
||||||
|
open = false;
|
||||||
|
break;
|
||||||
|
} else if (!open && tok->varId() == var->declarationId())
|
||||||
va_list_usedBeforeStartedError(tok, var->name());
|
va_list_usedBeforeStartedError(tok, var->name());
|
||||||
else if (exitOnEndOfStatement && tok->str() == ";")
|
else if (exitOnEndOfStatement && tok->str() == ";")
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -116,6 +116,18 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #6186
|
||||||
|
check("void Format(char* szFormat, char (*szBuffer)[_Size], ...) {\n"
|
||||||
|
" va_list arg_ptr;\n"
|
||||||
|
" va_start(arg_ptr, szBuffer);\n"
|
||||||
|
" try {\n"
|
||||||
|
" throw sth;\n"
|
||||||
|
" } catch(...) {\n"
|
||||||
|
" va_end(arg_ptr);\n"
|
||||||
|
" }\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void Format(char* szFormat, char (*szBuffer)[_Size], ...) {\n"
|
check("void Format(char* szFormat, char (*szBuffer)[_Size], ...) {\n"
|
||||||
" va_list arg_ptr;\n"
|
" va_list arg_ptr;\n"
|
||||||
" va_start(arg_ptr, szBuffer);\n"
|
" va_start(arg_ptr, szBuffer);\n"
|
||||||
|
|
Loading…
Reference in New Issue