[cups.bugs] [cppcheck] found a resource leak in trunk/cups/monitor/tbcp.c

Michael Sweet msweet at apple.com
Mon Mar 15 08:32:29 PDT 2010


Return from main() will close any open files.

On Mar 14, 2010, at 7:03 AM, Ettl Martin wrote:

> during a check of the current trunk with the static code analysis tool cppcheck (http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page), the tool discovered a resource leak in trunk/cups/monitor/tbcp.c
> 
> Please refert the attached patch that fixes the issue.
> 
> Best regards
> 
> Ettl Martin
> 
> 
> Here is the patch:
> 
> Index: tbcp.c
> ===================================================================
> --- tbcp.c	(Revision 9039)
> +++ tbcp.c	(Arbeitskopie)
> @@ -94,6 +94,7 @@
>     if (psgets(line, &linelen, fp) == NULL)
>     {
>       fputs("ERROR: Empty print file!\n", stderr);
> +      fclose(fp);
>       return (1);
>     }
> 
> @@ -145,7 +146,7 @@
> 
>     fflush(stdout);
>   }
> -
> +  fclose(fp);
>   return (0);
> }
> 
> 
> 
> 
> _______________________________________________
> cups-bugs mailing list
> cups-bugs at easysw.com
> http://lists.easysw.com/mailman/listinfo/cups-bugs

________________________________________________________________________
Michael Sweet, Senior Printing System Engineer, PWG Chair








More information about the cups mailing list