Opened 18 years ago

Closed 18 years ago

Last modified 17 years ago

#3 closed defect (wontfix)

Does not detect second similar leak place

Reported by: kimmov Owned by: noone
Priority: major Milestone:
Component: Other Version:
Keywords: Cc: kimmov@…, sigra

Description (last modified by hyd_danmar)

This kind of pattern:

Cls * p = new Cls;
[...]
if (condition)
	return;
if (condition2)
	return;
delete p;

rightfully gives error "Memory leak: p". But it points only second return line in the pattern. The first return line is leak as well.

Noticed this with WinMerge 2.13.1 codebase. ChildFrm.cpp (not from 2.13.1 but current SVN) also attached.

Outputs error:
[ChildFrm.cpp:202]: Memory leak: pWnd

Should also output:
[ChildFrm.cpp:195]: Memory leak: pWnd

Attachments (1)

ChildFrm.cpp (22.5 KB ) - added by kimmov 18 years ago.
ChildFrm.cpp from WinMerge SVN

Download all attachments as: .zip

Change History (6)

by kimmov, 18 years ago

Attachment: ChildFrm.cpp added

ChildFrm.cpp from WinMerge SVN

comment:1 by kimmov, 18 years ago

Forgot to mention that must run cppcheck with --all switch to see the error. And cppcheck version is current SVN (r992).

comment:2 by hyd_danmar, 18 years ago

Description: modified (diff)

comment:3 by hyd_danmar, 18 years ago

I think this is because the simplifycode will reduce multiple "if return ; if return ;" into a single "if return".

If so.. fixing this memory leak will cause cppcheck to detect the other memory leak and report that.

If all this is true then it's "ok" behaviour.

comment:4 by hyd_danmar, 18 years ago

Resolution: wontfix
Status: newclosed

this is "ok" behaviour as discussed above

comment:5 by sigra, 17 years ago

Cc: sigra added
Note: See TracTickets for help on using tickets.