Detlef Riekenberg : shlwapi: Return the correct length from GetAcceptLanguagesA.
Alexandre Julliard
julliard at winehq.org
Fri Feb 12 10:17:44 CST 2010
Module: wine
Branch: master
Commit: b14a08f38819d8e799525a08024a2a18746c5c7a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b14a08f38819d8e799525a08024a2a18746c5c7a
Author: Detlef Riekenberg <wine.dev at web.de>
Date: Thu Feb 11 22:57:21 2010 +0100
shlwapi: Return the correct length from GetAcceptLanguagesA.
---
dlls/shlwapi/ordinal.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/dlls/shlwapi/ordinal.c b/dlls/shlwapi/ordinal.c
index 60ce0d1..315208c 100644
--- a/dlls/shlwapi/ordinal.c
+++ b/dlls/shlwapi/ordinal.c
@@ -526,6 +526,8 @@ HRESULT WINAPI GetAcceptLanguagesA( LPSTR langbuf, LPDWORD buflen)
DWORD buflenW, convlen;
HRESULT retval;
+ TRACE("(%p, %p) *%p: %d\n", langbuf, buflen, buflen, buflen ? *buflen : -1);
+
if(!langbuf || !buflen || !*buflen) return E_FAIL;
buflenW = *buflen;
@@ -535,11 +537,20 @@ HRESULT WINAPI GetAcceptLanguagesA( LPSTR langbuf, LPDWORD buflen)
if (retval == S_OK)
{
convlen = WideCharToMultiByte(CP_ACP, 0, langbufW, -1, langbuf, *buflen, NULL, NULL);
+ convlen--; /* do not count the terminating 0 */
}
else /* copy partial string anyway */
{
convlen = WideCharToMultiByte(CP_ACP, 0, langbufW, *buflen, langbuf, *buflen, NULL, NULL);
- if (convlen < *buflen) langbuf[convlen] = 0;
+ if (convlen < *buflen)
+ {
+ langbuf[convlen] = 0;
+ convlen--; /* do not count the terminating 0 */
+ }
+ else
+ {
+ convlen = *buflen;
+ }
}
*buflen = buflenW ? convlen : 0;
More information about the wine-cvs
mailing list