Bug 221190

Summary: [cppcheck] found a resource leak in kdebase/workspace/kcheckpass/kcheckpass.c
Product: kscreensaver Reporter: ettl.martin
Component: kcheckpassAssignee: kscreensaver bugs tracking <kscreensaver-bugs-null>
Status: RESOLVED INTENTIONAL    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Other   
Latest Commit: Version Fixed In:
Attachments: proper fix

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.