Bug Fix: WM_GETTEXT should return NULL string if LB_GETCURSEL is LB_ERR

Carl Sopchak carl.sopchak at cegis123.com
Mon Jul 15 12:20:59 CDT 2002

I found this while trying to get Quicken 2000 Deluxe to run under wine.  Q2k
was crashing when adding a new security (stock) if nothing was seleted in the
Asset Class ListBox.  (It doesn't do this under "real Win NT"...)  It turns
out that Q2k seems to keep processing the value returned by WM_GETTEXT
regardless of the number of characters WM_GETTEXT returns.  Since wine's
WM_GETTEXT was not returning a NULL string (='\0'), a subsequent strcpy (or
some such) was choking because the string was not null terminated.

The attached patch sets the return string to '\0' if LB_GETCURSEL returns
LB_ERR.  (Although this behaviour is not specified on msdn.microsoft.com, I
figure it can't hurt, since the program calling WM_GETTEXT should be
expecting the buffer to get changed by the call...)  I don't know (and have
not checked) to see if other *_GETTEXT message handlers need to do the

One last point:  I'm fairly new at C coding.  If there's a better way to do
what this patch does, feel free to improve upon it... <grin>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-WM_GETTEXT-ReturnNullStr.patch
Type: text/x-diff
Size: 598 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20020715/a4e3ad03/patch-WM_GETTEXT-ReturnNullStr.bin

More information about the wine-patches mailing list