[Rd] [PATCH] Fix memory leak in PicTeXDeviceDriver

Steve Grubb sgrubb at redhat.com
Thu Jul 20 23:06:52 CEST 2017


Hello,

This patch fixes a memory leak due to ptd going out of scope
before its assigned to dd.

Signed-off-by: Steve Grubb <sgrubb at redhat.com>

Index: src/library/grDevices/src/devPicTeX.c
===================================================================
--- src/library/grDevices/src/devPicTeX.c	(revision 72935)
+++ src/library/grDevices/src/devPicTeX.c	(working copy)
@@ -665,8 +665,10 @@
     ptd->width = width;
     ptd->height = height;
 
-    if( ! PicTeX_Open(dd, ptd) ) 
+    if( ! PicTeX_Open(dd, ptd) ) {
+        free(ptd);
 	return FALSE;
+    }
 
     /* Base Pointsize */
     /* Nominal Character Sizes in Pixels */



More information about the R-devel mailing list