Fixed #3862 (Double deallocation does not take throws into account)
This commit is contained in:
parent
a823d29da3
commit
0cf2c2b327
|
@ -393,7 +393,7 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken,
|
|||
}
|
||||
|
||||
// return
|
||||
else if (tok->str() == "return") {
|
||||
else if (tok->str() == "return" || tok->str() == "throw") {
|
||||
ret(tok, *varInfo);
|
||||
varInfo->clear();
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ private:
|
|||
TEST_CASE(return1);
|
||||
TEST_CASE(return2);
|
||||
TEST_CASE(return3);
|
||||
TEST_CASE(return4);
|
||||
|
||||
// General tests: variable type, allocation type, etc
|
||||
TEST_CASE(test1);
|
||||
|
@ -381,6 +382,17 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void return4() {
|
||||
check("void f(char *p, int x) {\n"
|
||||
" if (x==12) {n"
|
||||
" free(p);\n"
|
||||
" throw 1;\n"
|
||||
" }\n"
|
||||
" free(p);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void test1() { // 3809
|
||||
check("void f(double*&p) {\n"
|
||||
" p = malloc(0x100);\n"
|
||||
|
|
Loading…
Reference in New Issue