[gs-commits] rev 11588 - trunk/gs/base

alexcher at ghostscript.com alexcher at ghostscript.com
Mon Aug 2 13:49:05 UTC 2010


Author: alexcher
Date: 2010-08-02 13:49:03 +0000 (Mon, 02 Aug 2010)
New Revision: 11588

Modified:
   trunk/gs/base/gp_upapr.c
Log:
Fix a memory leak. Free the paper name string allocated amd 
returned by libpaper.


Modified: trunk/gs/base/gp_upapr.c
===================================================================
--- trunk/gs/base/gp_upapr.c	2010-08-02 09:20:04 UTC (rev 11587)
+++ trunk/gs/base/gp_upapr.c	2010-08-02 13:49:03 UTC (rev 11588)
@@ -37,19 +37,20 @@
     if (!paper) paper = defaultpapername();
 
     if (paper) {
-	int len = strlen(paper);
+	int rc, len = strlen(paper);
 
 	if (len < *plen) {
 	    /* string fits */
 	    strcpy(ptr, paper);
-	    *plen = len + 1;
-	    paperdone();
-	    return 0;
+	    rc = 0;
+	} else {
+	    /* string doesn't fit */
+	    rc = -1;
 	}
-	/* string doesn't fit */
 	*plen = len + 1;
 	paperdone();
-	return -1;
+	free(paper);
+	return rc;
     }
 #endif
 



More information about the gs-commits mailing list