diff --git a/lib/checkother.cpp b/lib/checkother.cpp index a22ed3229..62f69286a 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -594,7 +594,7 @@ void CheckOther::checkRedundantAssignment() std::set initialized; const Token* writtenArgumentsEnd = 0; - for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) { + for (const Token* tok = scope->classStart->next(); tok && tok != scope->classEnd; tok = tok->next()) { if (tok == writtenArgumentsEnd) writtenArgumentsEnd = 0; diff --git a/test/testother.cpp b/test/testother.cpp index c693919e2..2b221dbdf 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1945,6 +1945,17 @@ private: " s->dyn_ltree[0].fc.freq++;\n" "}\n", 0, false, false, false, false); ASSERT_EQUALS("", errout.str()); + + // Ticket #6132 "crash: daca: kvirc CheckOther::checkRedundantAssignment()" + check("void HttpFileTransfer :: transferTerminated ( bool bSuccess@1 ) {\n" + "if ( m_szCompletionCallback . isNull ( ) ) {\n" + "KVS_TRIGGER_EVENT ( KviEvent_OnHTTPGetTerminated , out ? out : ( g_pApp . activeConsole ( ) ) , & vParams )\n" + "} else {\n" + "KviKvsScript :: run ( m_szCompletionCallback , out ? out : ( g_pApp . activeConsole ( ) ) , & vParams ) ;\n" + "}\n" + "}\n", 0, false, false, false, true); + ASSERT_EQUALS("", errout.str()); + } void switchRedundantOperationTest() {