checkautovariable: fix #7818, crash when accessing nullpointer tok2->next().

Not test case added yet because I failed to add it as .h files to testgarbage.
This commit is contained in:
Matthias Krüger 2016-11-16 14:46:37 +01:00
parent 2832b61a7c
commit a5d32aa7a5
1 changed files with 1 additions and 1 deletions

View File

@ -471,7 +471,7 @@ void CheckAutoVariables::returnReference()
// have we reached a function that returns a reference? // have we reached a function that returns a reference?
if (tok->previous() && tok->previous()->str() == "&") { if (tok->previous() && tok->previous()->str() == "&") {
for (const Token *tok2 = scope->classStart->next(); tok2 && tok2 != scope->classEnd; tok2 = tok2->next()) { for (const Token *tok2 = scope->classStart->next(); tok2 && tok2 != scope->classEnd && tok2->next(); tok2 = tok2->next()) {
if (!tok2->scope()->isExecutable()) { if (!tok2->scope()->isExecutable()) {
tok2 = tok2->scope()->classEnd; tok2 = tok2->scope()->classEnd;
continue; continue;