RESUBMIT: Quicken 2000 bug/Category blanking => Wine patch

Dimitrie O. Paun dpaun at rogers.com
Wed Aug 14 13:03:48 CDT 2002


On August 14, 2002 01:53 pm, Carl Sopchak wrote:
> It was suggested to me that I should not use strlen(), since I'm not
> positive if the string will ever really terminate (which may cause a seg
> fault), so I programmed my own scan for a null character..
>
> Here's the revised patch (attached).

What about this:


--- controls/edit.c     13 Jun 2002 19:20:43 -0000      1.95
+++ controls/edit.c     14 Aug 2002 17:49:13 -0000
@@ -3957,20 +3957,25 @@
  */
 static INT EDIT_WM_GetText(EDITSTATE *es, INT count, LPARAM lParam, BOOL unicode)
 {
+    INT ii;
+    
     if(!count) return 0;
 
     if(unicode)
     {
        LPWSTR textW = (LPWSTR)lParam;
        strncpyW(textW, es->text, count);
-       textW[count - 1] = 0; /* ensure 0 termination */
+       for (ii = 0; (ii < count) & textW[ii]; i++) ;
+       textW[ii - 1] = 0; /* force 0 termination */
        return strlenW(textW);
     }
     else
     {
        LPSTR textA = (LPSTR)lParam;
        WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, count, NULL, NULL);
-       textA[count - 1] = 0; /* ensure 0 termination */
+       for (ii = 0; (ii < count) & textA[ii]; i++) ;
+       textA[ii - 1] = 0; /* force 0 termination */
        return strlen(textA);
     }
 }

Untested :)

-- 
Dimi.




More information about the wine-devel mailing list