lstrlen(A/W) patch

Clinton Stimpson clinton at elemtech.com
Tue Jun 6 20:34:01 CDT 2006


Mike McCormack wrote:
>
> Clinton Stimpson wrote:
>
>> The following patch will fix the crash.
>> MSDN documentation says "*lstrlen* assumes that /lpString/ is a 
>> null-terminated string, or NULL"
>
> The inline lstrlenW is used only internally by Wine code, and we want 
> it to crash when passed a NULL pointer.  In this case, you should fix 
> the Wine code calling lstrlenW to not use a NULL pointer.
>
> Mike

Mike,

Oh, used internally, ok (I thought it was public and that the wine 
debugger said Paf 5.2 called that lstrlenW directly).
So here's another patch that fixes a crash in Personal Ancestral File 
5.2 when opening notes for an individual that has no notes.
I'm not sure that's how it is supposed to be fixed, but at least you can 
see that the root of the crash is a EM_SETTEXTEX message with lParam = NULL.

Also, it looks like bugs 4344 and 4585 were fixed quite recently.

Thanks,
Clint

Index: caret.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/caret.c,v
retrieving revision 1.27
diff -u -r1.27 caret.c
--- caret.c     23 May 2006 12:48:31 -0000      1.27
+++ caret.c     7 Jun 2006 01:16:34 -0000
@@ -382,8 +382,10 @@
     ME_DeleteSelection(editor);

   assert(nCursor>=0 && nCursor<editor->nCursors);
-  if (len == -1)
+  if (len == -1 && str)
     len = lstrlenW(str);
+  else if(len == -1)
+    len = 0;
   while (len)
   {
     pos = str;
Index: editor.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/editor.c,v
retrieving revision 1.108
diff -u -r1.108 editor.c
--- editor.c    23 May 2006 12:48:31 -0000      1.108
+++ editor.c    7 Jun 2006 01:16:34 -0000
@@ -1591,7 +1591,9 @@
   {
     LPWSTR wszText = (LPWSTR)lParam;
     SETTEXTEX *pStruct = (SETTEXTEX *)wParam;
-    size_t len = lstrlenW(wszText);
+    size_t len = 0;
+    if(wszText)
+      len = lstrlenW(wszText);
     int from, to;
     ME_Style *style;
     TRACE("EM_SETTEXEX - %s, flags %d, cp %d\n", debugstr_w(wszText), 
(int)pStruct->flags, pStruct->codepage);




More information about the wine-devel mailing list