From cd11f29ce1b381937dcd56ec966ba8abab845222 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Fri, 6 Nov 1998 10:58:33 +0000 Subject: [PATCH] The API for WideCharToMultiByte says that the src-string has only to be treated as NULL-terminated if srclen is -1. --- win32/code_page.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/win32/code_page.c b/win32/code_page.c index 2cdf09e5d6..2c395c220b 100644 --- a/win32/code_page.c +++ b/win32/code_page.c @@ -178,6 +178,7 @@ INT32 WINAPI WideCharToMultiByte(UINT32 page, DWORD flags, LPCWSTR src, { int count = 0; int eos = 0; + int care_for_eos=0; int dont_copy= (dstlen==0); if ((!src) | ((!dst) && (!dont_copy)) ) @@ -194,7 +195,10 @@ INT32 WINAPI WideCharToMultiByte(UINT32 page, DWORD flags, LPCWSTR src, if(used) *used=0; if (srclen == -1) + { srclen = lstrlen32W(src)+1; + care_for_eos=1; + } while(srclen && (dont_copy || dstlen)) { if(!dont_copy){ @@ -215,7 +219,7 @@ INT32 WINAPI WideCharToMultiByte(UINT32 page, DWORD flags, LPCWSTR src, } count++; srclen--; - if(!*src) { + if((!*src) && care_for_eos) { eos = 1; break; }