| 724 | } |
| 725 | |
| 726 | bool CheckMemoryLeakStructMemberImpl::isMalloc(const Variable *variable) const |
| 727 | { |
| 728 | if (!variable) |
| 729 | return false; |
| 730 | const int declarationId(variable->declarationId()); |
| 731 | bool alloc = false; |
| 732 | for (const Token *tok2 = variable->nameToken(); tok2 && tok2 != variable->scope()->bodyEnd; tok2 = tok2->next()) { |
| 733 | if (Token::Match(tok2, "= %varid% [;=]", declarationId)) |
| 734 | return false; |
| 735 | if (Token::Match(tok2, "%varid% =", declarationId)) { |
| 736 | const Token* tok3 = tok2->tokAt(1)->astOperand2(); |
| 737 | while (tok3 && tok3->isCast()) |
| 738 | tok3 = tok3->astOperand2() ? tok3->astOperand2() : tok3->astOperand1(); |
| 739 | if ((tok3 && Token::Match(tok3->tokAt(-1), "%name% (") && mSettings.library.getAllocFuncInfo(tok3->tokAt(-1))) || |
| 740 | (Token::simpleMatch(tok3, "new") && tok3->isCpp())) { |
| 741 | alloc = true; |
| 742 | } |
| 743 | } |
| 744 | } |
| 745 | return alloc; |
| 746 | } |
| 747 | |
| 748 | void CheckMemoryLeakStructMemberImpl::checkStructVariable(const Variable* const variable) const |
| 749 | { |
nothing calls this directly
no test coverage detected