wineps fix

Andreas Mohr a.mohr at mailto.de
Sat Apr 14 16:04:14 CDT 2001


Hi all,

[debugged on #WineHQ]

PSDRV_Text was being called with a count of 0 by a certain program
(probably via ExtTextOut or such).

This caused horrible death here:
    GetTextExtentPoint32W(dc->hSelf, str, count, &sz);
    if(lpDx) {
        SIZE tmpsz;
        INT i;
        /* Get the width of the last char and add on all the offsets */
        GetTextExtentPoint32W(dc->hSelf, str + count - 1, 1, &tmpsz);
        for(i = 0; i < count-1; i++)
            tmpsz.cx += lpDx[i];
        sz.cx = tmpsz.cx; /* sz.cy remains untouched */
    }

(underflow in the for loop)

I decided to just exit immediately in case the character count is 0.

If this is not a good fix, then could you please do a better one, Huw ?

Thanks !

-- 
Andreas Mohr                        Stauferstr. 6, D-71272 Renningen, Germany
Tel. +49 7159 800604                http://home.germany.net/100-30936/
-------------- next part --------------
Determining best CVS host...
Using CVSROOT :pserver:cvs at winehq.tiepmiep.dk:/home/wine
Index: dlls/wineps/text.c
===================================================================
RCS file: /home/wine/wine/dlls/wineps/text.c,v
retrieving revision 1.6
diff -u -r1.6 text.c
--- dlls/wineps/text.c	2001/02/12 01:21:34	1.6
+++ dlls/wineps/text.c	2001/04/14 21:59:01
@@ -81,6 +81,9 @@
     LPWSTR strbuf;
     SIZE sz;
 
+    if (!count)
+	return TRUE;
+
     strbuf = HeapAlloc( PSDRV_Heap, 0, (count + 1) * sizeof(WCHAR));
     if(!strbuf) {
         WARN("HeapAlloc failed\n");


More information about the wine-patches mailing list