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

Ettl Martin ettl.martin at gmx.de
Sun Mar 14 11:27:03 PDT 2010


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);
       }





More information about the cups-devel mailing list