Bug 221190 - [cppcheck] found a resource leak in kdebase/workspace/kcheckpass/kcheckpass.c
Summary: [cppcheck] found a resource leak in kdebase/workspace/kcheckpass/kcheckpass.c
Status: RESOLVED INTENTIONAL
Alias: None
Product: kscreensaver
Classification: Miscellaneous
Component: kcheckpass (show other bugs)
Version: unspecified
Platform: Compiled Sources Other
: NOR normal
Target Milestone: ---
Assignee: kscreensaver bugs tracking
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-04 00:31 UTC by ettl.martin
Modified: 2010-02-15 00:34 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
proper fix (336 bytes, patch)
2010-01-04 00:32 UTC, ettl.martin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ettl.martin 2010-01-04 00:31:30 UTC
Version:           svn head (using Devel)
OS:                Other
Installed from:    Compiled sources

during a check of kdebase sources (current svn-head) with the static code analysis tool cppcheck (http://sourceforge.net/projects/cppcheck/) the tool discovered a resource leak at kdebase/workspace/kcheckpass/kcheckpass.c. 

Please refer the attached patch that fixes the issue.

Best regards

Ettl Martin


Index: kcheckpass.c
===================================================================
--- kcheckpass.c	(Revision 1069610)
+++ kcheckpass.c	(Arbeitskopie)
@@ -408,6 +408,7 @@
     lk.l_start = lk.l_len = 0;
     if (fcntl(lfd, F_SETLKW, &lk)) {
       message("Cannot obtain lock\n");
+	  close(lfd);
       return AuthError;
     }
Comment 1 ettl.martin 2010-01-04 00:32:32 UTC
Created attachment 39540 [details]
proper fix
Comment 2 Oswald Buddenhagen 2010-02-15 00:34:41 UTC
this is a return statement from the main() function. there is absolutely no point in closing the fd manually at this point.