From a4d597451b5d127fa692e2cf119973053851ecbd Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Thu, 24 Jul 2014 16:54:20 +0400 Subject: [PATCH] Resolve CID 1214637. --- lib/checkclass.cpp | 15 +++++++++------ lib/checkclass.h | 5 +++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index efcb705e3..121b02d58 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1190,7 +1190,13 @@ void CheckClass::operatorEqRetRefThis() } } -void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last, std::set* analyzedFunctions) +void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last) +{ + std::set analyzedFunctions; + checkReturnPtrThis(scope, func, tok, last, analyzedFunctions); +} + +void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last, std::set& analyzedFunctions) { bool foundReturn = false; @@ -1219,11 +1225,8 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co if (!it->isConst) { /** @todo make sure argument types match */ // avoid endless recursions - if (!analyzedFunctions || analyzedFunctions->find(&*it)==analyzedFunctions->end()) { - std::set local_analyzedFunctions; - if (!analyzedFunctions) - analyzedFunctions=&local_analyzedFunctions; - analyzedFunctions->insert(&*it); + if (analyzedFunctions.find(&*it) == analyzedFunctions.end()) { + analyzedFunctions.insert(&*it); checkReturnPtrThis(scope, &*it, it->arg->link()->next(), it->arg->link()->next()->link(), analyzedFunctions); } diff --git a/lib/checkclass.h b/lib/checkclass.h index 8540ce1a1..5ef1fc2d6 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -201,8 +201,9 @@ private: "* Duplicated inherited data members\n"; } - // operatorEqRetRefThis helper function - void checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last, std::set* analyzedFunctions=nullptr); + // operatorEqRetRefThis helper functions + void checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last); + void checkReturnPtrThis(const Scope *scope, const Function *func, const Token *tok, const Token *last, std::set& analyzedFunctions); // operatorEqToSelf helper functions bool hasAllocation(const Function *func, const Scope* scope) const;