File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -282,7 +282,17 @@ static const Token * isFunctionCall(const Token * nameToken)
282282static const Token * isAnonymousFunctionCall (const Token * tok)
283283{
284284 // match one of the supported LHS patterns
285- if (tok->previous ()->str () == " (" && !tok->previous ()->isBinaryOp () && tok->linkAt (-1 )) {
285+ // TODO: check if tok->previous()->isCast(). can't right now because
286+ //
287+ // auto x = [](void *ptr) { g(ptr) };
288+ // void *p = malloc(1);
289+ // (x)(p);
290+ // ^
291+ // the lpar surrounding x has isCast() == true, so checking isCast() would
292+ // have false positive leaks, while allowing casts to take ownership of
293+ // resources is instead a false negative
294+ if (tok->previous ()->str () == " (" && !tok->previous ()->isBinaryOp () &&
295+ tok->linkAt (-1 ) && !tok->isStandardType ()) {
286296 tok = tok->linkAt (-1 )->next ();
287297 } else if (!tok->isStandardType () && tok->isName () && tok->linkAt (1 )) {
288298 tok = tok->linkAt (1 )->next ();
You can’t perform that action at this time.
0 commit comments