WideCharToMultiByte normally null-terminates the output if input length is -1, but it doesn't do so if the output buffer is too small.
From: Yuxuan Shui yshui@codeweavers.com
WideCharToMultiByte normally null-terminates the output if input length is -1, but it doesn't do so if the output buffer is too small. --- dlls/dsound/dsound_main.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c index bb373a4304d..b0874e3e675 100644 --- a/dlls/dsound/dsound_main.c +++ b/dlls/dsound/dsound_main.c @@ -299,7 +299,9 @@ static BOOL CALLBACK a_to_w_callback(LPGUID guid, LPCWSTR descW, LPCWSTR modW, L char descA[MAXPNAMELEN], modA[MAXPNAMELEN];
WideCharToMultiByte(CP_ACP, 0, descW, -1, descA, sizeof(descA), NULL, NULL); + descA[sizeof(descA)-1] = 0; WideCharToMultiByte(CP_ACP, 0, modW, -1, modA, sizeof(modA), NULL, NULL); + modA[sizeof(modA)-1] = 0;
return context->callA(guid, descA, modA, context->data); }
I don't think we limit them in W functions, when mmdevapi friendly names are used, so this probably should be dynamically allocated?