steam_helper: Null terminate escape_path_unix_to_dos.

WideCharToMultiByte does not null terminate if a null character is not
included in the input length.

CW-Bug-Id: #24534
This commit is contained in:
Yuxuan Shui 2025-07-04 12:09:54 +01:00 committed by Arkadiusz Hiler
parent 0b31734416
commit 340027e317

View File

@ -115,7 +115,11 @@ static char *escape_path_unix_to_dos( const char *path )
for (src = dos, dst = tmp; *src; src++, dst++) if ((*dst = *src) == '\\') *++dst = '\\';
if (!(len = WideCharToMultiByte( CP_UTF8, 0, tmp, (dst - tmp), NULL, 0, NULL, NULL ))) goto done;
if ((escaped = malloc( len ))) WideCharToMultiByte( CP_UTF8, 0, tmp, (dst - tmp), escaped, len, NULL, NULL );
if ((escaped = malloc( len + 1 )))
{
WideCharToMultiByte( CP_UTF8, 0, tmp, (dst - tmp), escaped, len, NULL, NULL );
escaped[len] = '\0';
}
done:
HeapFree( GetProcessHeap(), 0, dos );