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

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

 



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).

Carl

P.S., Thanks, for the feedback, Peter Ekberg!  (I did claim that I was NOT a C 
guru <grin>!)
Index: controls/edit.c
===================================================================
RCS file: /home/wine/wine/controls/edit.c,v
retrieving revision 1.95
diff -u -r1.95 edit.c
--- 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 isterm = 0;
+    INT ii = 0;
+    
     if(!count) return 0;
 
     if(unicode)
     {
 	LPWSTR textW = (LPWSTR)lParam;
 	strncpyW(textW, es->text, count);
-	textW[count - 1] = 0; /* ensure 0 termination */
+	while ((ii < count) & (!isterm)) { if (textW[ii++] == 0) { isterm = 1; } }
+	if (!isterm) textW[count - 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 */
+	while ((ii < count) & (!isterm)) { if (textA[ii++] == 0) { isterm = 1; } }
+	if (!isterm) textA[count - 1] = 0; /* force 0 termination */
 	return strlen(textA);
     }
 }

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

  Powered by Linux