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

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


Return from main() will close any open files.

On Mar 14, 2010, at 11:27 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/cups/testi18n.c
> 
> Please refer the attached patch that fixes the issue.
> 
> Best regards
> 
> Ettl Martin
> 
> Here is the patch:
> 
> Index: testi18n.c
> ===================================================================
> --- testi18n.c	(Revision 9039)
> +++ testi18n.c	(Arbeitskopie)
> @@ -183,6 +183,7 @@
>     if (encoding == CUPS_AUTO_ENCODING)
>     {
>       fprintf(stderr, "%s: Unknown character set!\n", argv[2]);
> +	  fclose(fp);
>       return (1);
>     }
> 
> @@ -191,7 +192,8 @@
>       if (cupsCharsetToUTF8(utf8dest, line, sizeof(utf8dest), encoding) < 0)
>       {
>         fprintf(stderr, "%s: Unable to convert line: %s", argv[1], line);
> -	return (1);
> +	  	fclose(fp);
> +		return (1);
>       }
> 
> _______________________________________________
> 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