This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: Plug memory leak in libgui/src/tkWinPrint*.c


Hi all.

I just added this patch. This code is not used by Insight
so there should be no need to worry about this change.

cheers
Mo

2001-08-02  Mo DeJong  <mdejong@redhat.com>

        * src/tkWinPrintCanvas.c (PrintCanvasCmd):
        * src/tkWinPrintText.c (PrintTextCmd): Plug
        memory leak by calling free on memory allocated
        in PrintCanvasCmd and PrintTextCmd method. Make
        sure error cases branch to the cleanup code at
        the end of the method instead of just returning.


Index: src/tkWinPrintCanvas.c
===================================================================
RCS file: /cvs/cvsfiles/devo/libgui/src/tkWinPrintCanvas.c,v
retrieving revision 1.4
diff -u -r1.4 tkWinPrintCanvas.c
--- tkWinPrintCanvas.c	1999/01/09 00:19:14	1.4
+++ tkWinPrintCanvas.c	2001/08/03 00:22:04
@@ -58,14 +58,14 @@
 	Tcl_AppendResult(interp, "wrong # args: should be \"",
 			 argv[0], " canvas \"",
 			 (char *) NULL);
-	return TCL_ERROR;
+	goto error;
     }
 
     /* The second arg is the canvas widget */
     if (!Tcl_GetCommandInfo(interp, argv[1], &canvCmd)) {
 	Tcl_AppendResult(interp, "couldn't get canvas information for \"",
 			 argv[1], "\"", (char *) NULL);
-	return TCL_ERROR;
+	goto error;
     }
     
     memset(&dm,0,sizeof(DEVMODE));
@@ -164,8 +164,12 @@
     EndDoc(pd.hDC);
 
 done:
+    free ((char*) lpdi->lpszDocName);
+    free (lpdi);
     return TCL_OK;
- error:
+error:
+    free ((char*) lpdi->lpszDocName);
+    free (lpdi);
     return TCL_ERROR;
 }
 
Index: src/tkWinPrintText.c
===================================================================
RCS file: /cvs/cvsfiles/devo/libgui/src/tkWinPrintText.c,v
retrieving revision 1.6.180.1
diff -u -r1.6.180.1 tkWinPrintText.c
--- tkWinPrintText.c	2001/08/02 21:56:44	1.6.180.1
+++ tkWinPrintText.c	2001/08/03 00:22:04
@@ -273,7 +273,7 @@
 	Tcl_AppendResult(interp, "wrong # args: should be \"",
 			 argv[0], " text \"",
 			 (char *) NULL);
-	return TCL_ERROR;
+	goto error;
     }
 
     /*
@@ -282,7 +282,7 @@
     if (!Tcl_GetCommandInfo(interp, argv[1], &textCmd)) {
 	Tcl_AppendResult(interp, "couldn't get text information for \"",
 			 argv[1], "\"", (char *) NULL);
-	return TCL_ERROR;
+	goto error;
     }
     
     memset(&dm,0,sizeof(DEVMODE));
@@ -446,8 +446,12 @@
     textPtr->dInfoPtr->flags|=DINFO_OUT_OF_DATE;
 
 done:
+    free ((char*) lpdi->lpszDocName);
+    free (lpdi);
     return TCL_OK;
- error:
+error:
+    free ((char*) lpdi->lpszDocName);
+    free (lpdi);
     return TCL_ERROR;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]