dlls/user/text.c division by zero - alternative fix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bill Medland (medbi01@accpac.com)
Better handling of bad data in TabbedTextOut/TabbedTextExtent
Checked with:
a) Null tabstop array with non-zero number of entries
b) Negative number of entries (MSDN is wrong; it is not an error)
c) Single tabwidth of negative size
d) Single specified tabwidth of zero size

Index: wine/dlls/user/text.c
===================================================================
RCS file: /home/wine/wine/dlls/user/text.c,v
retrieving revision 1.43
diff -u -r1.43 text.c
--- wine/dlls/user/text.c	8 Jan 2003 21:09:26 -0000	1.43
+++ wine/dlls/user/text.c	30 Jan 2003 18:22:16 -0000
@@ -1216,7 +1216,10 @@
     extent.cx = 0;
     extent.cy = 0;
 
-    if (cTabStops == 1)
+    if (!lpTabPos)
+        cTabStops=0;
+
+    if (cTabStops == 1 && *lpTabPos >= /* sic */ 0)
     {
         defWidth = *lpTabPos;
         cTabStops = 0;
@@ -1226,6 +1229,8 @@
         TEXTMETRICA tm;
         GetTextMetricsA( hdc, &tm );
         defWidth = 8 * tm.tmAveCharWidth;
+        if (cTabStops == 1)
+            cTabStops = 0; /* on negative *lpTabPos */
     }
 
     while (count > 0)
@@ -1243,6 +1248,8 @@
             tabPos = x + extent.cx;
         else if (cTabStops > 0)
             tabPos = nTabOrg + *lpTabPos;
+        else if (defWidth <= 0)
+            tabPos = x + extent.cx;
         else
             tabPos = nTabOrg + ((x + extent.cx - nTabOrg) / defWidth + 1) * defWidth;
         if (fDisplayText)

-- 
Bill Medland
ACCPAC International, Inc.
medbi01@accpac.com
Corporate: www.accpac.com
Hosted Services: www.accpaconline.com


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux