[try 3] user32: GetMenuStringA now returns correct buffer length for multibyte menu text.

Huang, Zhangrong hzhrong at gmail.com
Wed Jul 16 09:59:55 CDT 2008


Hi,

This time I don't add test code, since we can found this problem by
code reviewing.

Pls see GetMenuStringA in dlls/user32/menu.c:

INT WINAPI GetMenuStringA(
       HMENU hMenu,    /* [in] menuhandle */
       UINT wItemID,   /* [in] menu item (dep. on wFlags) */
       LPSTR str,      /* [out] outbuffer. If NULL, func returns entry length*/
       INT nMaxSiz,    /* [in] length of buffer. if 0, func returns entry len*/
       UINT wFlags     /* [in] MF_ flags */
) {
..............................
   if (!str || !nMaxSiz) return strlenW(item->text);
.....................................
}

If outbuffer is NULL or nMaxSiz is 0, GetMenuStringA should return
entry length of menu text.
If menu text is multibyte, for example, two multibyte chars need 4
bytes, but strlenW only returns 2 bytes, so we need call
WideCharToMultiByte to get correct buffer length.

ChangeLog:
   user32: GetMenuStringA now returns correct buffer length for
multibyte menu text.


-- 
$ apt-get moo
 (__)
 (oo)
 /------\/
 / | ||
 * /\---/\
 ~~ ~~
...."Have you mooed today?"...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-user32-GetMenuStringA-now-returns-correct-buffer-le.patch
Type: application/mbox
Size: 929 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20080716/5a7d1de9/attachment-0001.bin 


More information about the wine-patches mailing list