Skip to content

Commit ac3b1c0

Browse files
IOBYTEdanmar
authored andcommitted
Fixed cppcheck-opensource#5134 (Memory leak below CheckIO::checkWrongPrintfScanfArguments())
1 parent 3e13408 commit ac3b1c0

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

lib/checkio.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,16 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings)
14211421
}
14221422
}
14231423

1424+
CheckIO::ArgumentInfo::~ArgumentInfo()
1425+
{
1426+
if (tempToken) {
1427+
while (tempToken->next())
1428+
tempToken->deleteNext();
1429+
1430+
delete tempToken;
1431+
}
1432+
}
1433+
14241434
bool CheckIO::ArgumentInfo::isStdVectorOrString()
14251435
{
14261436
if (Token::Match(variableInfo->typeStartToken(), "std :: vector|array <")) {

lib/checkio.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ class CPPCHECKLIB CheckIO : public Check {
7272
class ArgumentInfo {
7373
public:
7474
ArgumentInfo(const Token *arg, const Settings *settings);
75-
~ArgumentInfo() {
76-
delete tempToken;
77-
}
75+
~ArgumentInfo();
76+
7877
bool isArrayOrPointer() const;
7978
bool isComplexType() const;
8079
bool isKnownType() const;

0 commit comments

Comments
 (0)