shithub: puzzles

Download patch

ref: fb6e7f1a8ba72a7aa46be661c6e5f10f33ad94fc
parent: b0614e6da8f8a709e8fad797d7bb6ba05491ac79
author: Simon Tatham <anakin@pobox.com>
date: Mon Aug 22 14:46:38 EDT 2005

Memory leak in the new printing stuff, plus a couple of comment
corrections.

[originally from svn r6199]

--- a/windows.c
+++ b/windows.c
@@ -367,7 +367,6 @@
 	int width = thin ? 0 : fe->linewidth;
 
 	print_get_colour(fe->dr, colour, &hatch, &r, &g, &b);
-	/* FIXME: line thickness here */
 	if (fe->printcolour)
 	    pen = CreatePen(PS_SOLID, width,
 			    RGB(r * 255, g * 255, b * 255));
@@ -757,12 +756,7 @@
     frontend *fe = (frontend *)handle;
 
     assert(fe->drawstatus != DRAWING);
-    /*
-     * The MSDN web site sample code doesn't bother to call EndDoc
-     * if an error occurs half way through printing. I expect doing
-     * so would cause the erroneous document to actually be
-     * printed, or something equally undesirable.
-     */
+
     if (fe->drawstatus == NOTHING)
 	return;
 
@@ -790,6 +784,12 @@
     }
     fe->fontstart = 0;
 
+    /*
+     * The MSDN web site sample code doesn't bother to call EndDoc
+     * if an error occurs half way through printing. I expect doing
+     * so would cause the erroneous document to actually be
+     * printed, or something equally undesirable.
+     */
     if (fe->drawstatus == NOTHING)
 	return;
 
@@ -885,8 +885,10 @@
     pd.nFromPage = pd.nToPage = 0xFFFF;
     pd.nMinPage = pd.nMaxPage = 1;
 
-    if (!PrintDlg(&pd))
+    if (!PrintDlg(&pd)) {
+	document_free(doc);
 	return;
+    }
 
     /*
      * Now pd.hDC is a device context for the printer.
@@ -916,6 +918,7 @@
     fe->drawstatus = NOTHING;
 
     DeleteDC(pd.hDC);
+    document_free(doc);
 }
 
 void deactivate_timer(frontend *fe)