winmm: Initialize Memory in mciSendStringA

Rico Schüller kgbricola at web.de
Tue Mar 3 09:48:24 CST 2009


Alexandre Julliard schrieb:
> Rico Schüller <kgbricola at web.de> writes:
>
>   
>> @@ -1498,7 +1498,10 @@ DWORD WINAPI mciSendStringA(LPCSTR lpstrCommand, LPSTR lpstrRet,
>>      MultiByteToWideChar( CP_ACP, 0, lpstrCommand, -1, lpwstrCommand, len );
>>      if (lpstrRet)
>>      {
>> -        lpwstrRet = HeapAlloc(GetProcessHeap(), 0, uRetLen * sizeof(WCHAR));
>> +        /* Use HEAP_ZERO_MEMORY, otherwise WideCharToMultiByte could crash if mciSendStringW fails,
>> +         * because the length is taken from the uninizialized data!
>> +         */
>> +        lpwstrRet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, uRetLen * sizeof(WCHAR));
>>     
>
> That's just hiding the bug. The string shouldn't be converted at all if
> we failed to retrieve it.
>
>   
I'll have a look how this could be handled in another way. Probably 
something like if (lpwstrRet && ret==0) before the conversation.

Cheers
Rico



More information about the wine-devel mailing list