small printdlg patch

Andreas Mohr a.mohr at mailto.de
Fri Jul 27 16:47:56 CDT 2001


Hi all,

DeviceCapabilities() DC_PAPERNAMES on a HP 660c printer driver
somehow returned -1 (failure).

This might be because it's a brand new install on a PC I'm installing
right now.
(haven't even printed a single test page on the Win98SE install !)

Regardless of that failure, PRINTDLG_PaperSize shouldn't crash,
which it did, since it used the -1 index in a for loop -> memory address
overflow in strcmp().
Better don't continue in case of failure...

This fix lets Mathcad 2000 Professional finally start up, BTW ! :-))
(numerous font and repainting issues, though :-\)

-- 
Andreas Mohr                        Stauferstr. 6, D-71272 Renningen, Germany
-------------- next part --------------
Determining best CVS host...
Using CVSROOT :pserver:cvs at rhlx01.fht-esslingen.de:/home/wine
Index: dlls/commdlg/printdlg.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/printdlg.c,v
retrieving revision 1.46
diff -u -r1.46 printdlg.c
--- dlls/commdlg/printdlg.c	14 Jul 2001 00:47:20 -0000	1.46
+++ dlls/commdlg/printdlg.c	27 Jul 2001 19:43:19 -0000
@@ -377,7 +377,7 @@
     DEVMODEA	*dm;
     LPSTR	devname,portname;
     int		i;
-    DWORD	NrOfEntries,ret;
+    INT		NrOfEntries,ret;
     char	*Names = NULL;
     POINT	*points = NULL;
     BOOL	retval = FALSE;
@@ -393,9 +393,14 @@
 	FIXME("No papernames found for %s/%s\n",devname,portname);
 	goto out;
     }
+    if (NrOfEntries == -1) {
+	ERR("Hmm ? DeviceCapabilities() DC_PAPERNAMES failed, ret -1 !\n");
+	goto out;
+    }
+	    
     Names = (char*)HeapAlloc(GetProcessHeap(),0,NrOfEntries*64);
     if (NrOfEntries != (ret=DeviceCapabilitiesA(devname,portname,DC_PAPERNAMES,Names,dm))) {
-	FIXME("Number of returned vals %ld is not %ld\n",NrOfEntries,ret);
+	FIXME("Number of returned vals %d is not %d\n",NrOfEntries,ret);
 	goto out;
     }
     for (i=0;i<NrOfEntries;i++)
@@ -408,7 +413,7 @@
     }
     points = HeapAlloc(GetProcessHeap(),0,sizeof(points[0])*NrOfEntries);
     if (NrOfEntries!=(ret=DeviceCapabilitiesA(devname,portname,DC_PAPERSIZE,(LPBYTE)points,dm))) {
-	FIXME("Number of returned sizes %ld is not %ld?\n",NrOfEntries,ret);
+	FIXME("Number of returned sizes %d is not %d?\n",NrOfEntries,ret);
 	goto out;
     }
     /* this is _10ths_ of a millimeter */


More information about the wine-patches mailing list