Fixed #5144 (FP old memleak - tree structure)

This commit is contained in:
Daniel Marjamäki 2016-12-27 08:12:37 +01:00
parent 1b21767954
commit 85ae3adeb2
2 changed files with 17 additions and 0 deletions

View File

@ -386,6 +386,9 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::functionReturnType(const Function* f
if (Token::Match(tok, "[(,] & %varid% [.,)]", varid)) {
return No;
}
if (Token::Match(tok, "[;{}] %varid% .", varid)) {
return No;
}
if (allocType == No && tok->str() == "return")
return No;
}

View File

@ -2575,6 +2575,20 @@ private:
" char* s = data();\n"
"}");
ASSERT_EQUALS("", errout.str());
// #5144
check("C* BuildC( C *previous ) {\n"
" C *result = malloc(100);\n"
" result->previous = previous;\n"
" return result;\n"
"}\n"
"C *ParseC( ) {\n"
" C *expr1 = NULL;\n"
" while( something() )\n"
" expr1 = BuildC(expr1);\n"
" return expr1;\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void allocfunc8() {