combo: don't overwrite the string with CB_ADDSTRING
Huw D M Davies
h.davies1 at physics.ox.ac.uk
Mon Apr 25 11:41:42 CDT 2005
Huw Davies <huw at codeweavers.com>
The ansi version of CB_ADDSTRING shouldn't overwrite the
string if converting case.
--
Huw Davies
huw at codeweavers.com
Index: dlls/user/combo.c
===================================================================
RCS file: /home/wine/wine/dlls/user/combo.c,v
retrieving revision 1.8
diff -u -p -r1.8 combo.c
--- dlls/user/combo.c 23 Dec 2004 17:21:05 -0000 1.8
+++ dlls/user/combo.c 25 Apr 2005 16:39:43 -0000
@@ -1828,6 +1828,18 @@ static void COMBO_MouseMove( LPHEADCOMBO
}
}
+static char *strdupA(LPCSTR str)
+{
+ char *ret;
+ DWORD len;
+
+ if(!str) return NULL;
+
+ len = strlen(str);
+ ret = HeapAlloc(GetProcessHeap(), 0, len + 1);
+ memcpy(ret, str, len + 1);
+ return ret;
+}
/***********************************************************************
* ComboWndProc_common
@@ -2054,13 +2066,24 @@ static LRESULT ComboWndProc_common( HWND
struprW((LPWSTR)lParam);
return SendMessageW(lphc->hWndLBox, LB_ADDSTRING, 0, lParam);
}
- else
+ else /* unlike the unicode version, the ansi version does not overwrite
+ the string if converting case */
{
+ char *string = NULL;
+ LRESULT ret;
if( lphc->dwStyle & CBS_LOWERCASE )
- _strlwr((LPSTR)lParam);
+ {
+ string = strdupA((LPSTR)lParam);
+ _strlwr(string);
+ }
else if( lphc->dwStyle & CBS_UPPERCASE )
- _strupr((LPSTR)lParam);
- return SendMessageA(lphc->hWndLBox, LB_ADDSTRING, 0, lParam);
+ {
+ string = strdupA((LPSTR)lParam);
+ _strupr(string);
+ }
+ ret = SendMessageA(lphc->hWndLBox, LB_ADDSTRING, 0, string ? (LPARAM)string : lParam);
+ HeapFree(GetProcessHeap(), 0, string);
+ return ret;
}
case CB_INSERTSTRING16:
wParam = (INT)(INT16)wParam;
More information about the wine-patches
mailing list