From 721bc32b2d274711368385641221704d0ae09c98 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Mon, 20 Jun 2016 09:24:23 +0200 Subject: [PATCH] Fixed crash in CheckVaarg::va_list_usage() (#7559) --- lib/checkvaarg.cpp | 2 ++ test/testvaarg.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/checkvaarg.cpp b/lib/checkvaarg.cpp index 6f82643f5..1f90f9bf8 100644 --- a/lib/checkvaarg.cpp +++ b/lib/checkvaarg.cpp @@ -129,6 +129,8 @@ void CheckVaarg::va_list_usage() while (scope->nestedIn && scope->type != Scope::eFor && scope->type != Scope::eWhile && scope->type != Scope::eDo && scope->type != Scope::eSwitch) scope = scope->nestedIn; tok = scope->classEnd; + if (!tok) + return; } else if (_tokenizer->isCPP() && tok->str() == "try") { open = false; break; diff --git a/test/testvaarg.cpp b/test/testvaarg.cpp index 1ca905333..846f41c85 100644 --- a/test/testvaarg.cpp +++ b/test/testvaarg.cpp @@ -299,6 +299,17 @@ private: " BG_TString result(f);\n" "}"); ASSERT_EQUALS("", errout.str()); + + // #7559 + check("void mowgli_object_message_broadcast(mowgli_object_t *self, const char *name, ...) {\n" + " va_list va;\n" + " MOWGLI_LIST_FOREACH(n, self->klass->message_handlers.head) {\n" + " if (!strcasecmp(sig2->name, name))\n" + " break;\n" + " }\n" + " va_start(va, name);\n" + " va_end(va);\n" + "}"); } };