File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -363,6 +363,8 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::functionReturnType(const Function* f
363363 for (const Token *tok2 = func->functionScope ->bodyStart ; tok2 != func->functionScope ->bodyEnd ; tok2 = tok2->next ()) {
364364 if (const Token *endOfLambda = findLambdaEndToken (tok2))
365365 tok2 = endOfLambda;
366+ if (tok2->str () == " {" && !tok2->scope ()->isExecutable ())
367+ tok2 = tok2->link ();
366368 if (tok2->str () == " return" ) {
367369 const AllocType allocType = getAllocationType (tok2->next (), 0 , callstack);
368370 if (allocType != No)
Original file line number Diff line number Diff line change @@ -1928,6 +1928,15 @@ class TestMemleakNoVar : public TestFixture {
19281928 " }" );
19291929 ASSERT_EQUALS (" " , errout.str ());
19301930
1931+ check (" void *f() {\n " // #8848
1932+ " struct S { void *alloc() { return malloc(10); } };\n "
1933+ " }\n "
1934+ " void x()\n "
1935+ " {\n "
1936+ " f();\n "
1937+ " }" );
1938+ ASSERT_EQUALS (" " , errout.str ());
1939+
19311940 check (" void x()\n "
19321941 " {\n "
19331942 " if(!malloc(5)) fail();\n "
You can’t perform that action at this time.
0 commit comments