Fixed #4799: Improved quickfix from 0943fecf03
(Segmentation fault in K&R simplification inside lambda expression)
This commit is contained in:
parent
1936eb8676
commit
614a78084f
|
@ -5005,14 +5005,14 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, Token * tokEnd, bool only_k_r_
|
||||||
continue;
|
continue;
|
||||||
} else if (tok->str() == "(") {
|
} else if (tok->str() == "(") {
|
||||||
for (Token * tok2 = tok; tok2 != tok->link(); tok2 = tok2->next()) {
|
for (Token * tok2 = tok; tok2 != tok->link(); tok2 = tok2->next()) {
|
||||||
if (!only_k_r_fpar && isCPP() && Token::Match(tok2, "[(,] [")) {
|
if (isCPP() && Token::Match(tok2, "[(,] [")) {
|
||||||
// lambda function at tok2->next()
|
// lambda function at tok2->next()
|
||||||
// find start of lambda body
|
// find start of lambda body
|
||||||
Token * lambdaBody = tok2;
|
Token * lambdaBody = tok2;
|
||||||
while (lambdaBody && lambdaBody != tok2->link() && lambdaBody->str() != "{")
|
while (lambdaBody && lambdaBody != tok2->link() && lambdaBody->str() != "{")
|
||||||
lambdaBody = lambdaBody->next();
|
lambdaBody = lambdaBody->next();
|
||||||
if (lambdaBody && lambdaBody != tok2->link() && lambdaBody->link())
|
if (lambdaBody && lambdaBody != tok2->link() && lambdaBody->link())
|
||||||
simplifyVarDecl(lambdaBody, lambdaBody->link(), only_k_r_fpar);
|
simplifyVarDecl(lambdaBody, lambdaBody->link()->next(), only_k_r_fpar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
|
|
Loading…
Reference in New Issue