parent
0988448319
commit
951ca2c8b9
|
@ -764,6 +764,9 @@ const Token * CheckLeakAutoVar::checkTokenInsideExpression(const Token * const t
|
|||
break;
|
||||
rhs = rhs->astParent();
|
||||
}
|
||||
while (rhs->isCast()) {
|
||||
rhs = rhs->astOperand1();
|
||||
}
|
||||
if (rhs->varId() == tok->varId()) {
|
||||
// simple assignment
|
||||
varInfo->erase(tok->varId());
|
||||
|
|
|
@ -80,6 +80,7 @@ private:
|
|||
TEST_CASE(assign18);
|
||||
TEST_CASE(assign19);
|
||||
TEST_CASE(assign20); // #9187
|
||||
TEST_CASE(assign21); // #10186
|
||||
|
||||
TEST_CASE(isAutoDealloc);
|
||||
|
||||
|
@ -421,6 +422,20 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:3]: (error) Memory leak: p\n", errout.str());
|
||||
}
|
||||
|
||||
void assign21() { // #10186
|
||||
check("void f(int **x) {\n"
|
||||
" void *p = malloc(10);\n"
|
||||
" *x = p;\n"
|
||||
"}", true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(struct str *d) {\n"
|
||||
" void *p = malloc(10);\n"
|
||||
" d->a = p;\n"
|
||||
"}", true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void isAutoDealloc() {
|
||||
check("void f() {\n"
|
||||
" char *p = new char[100];"
|
||||
|
|
Loading…
Reference in New Issue