[PATCH] kernel32: Don't use the TEB static buffer in CreateFileA().
We might call GetModuleHandle("krnl386.exe16") later, which will overwrite the static buffer. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> --- dlls/kernel32/file.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c index 3e93b0d..5301eaf 100644 --- a/dlls/kernel32/file.c +++ b/dlls/kernel32/file.c @@ -1633,10 +1633,13 @@ HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access, DWORD sharing, DWORD attributes, HANDLE template) { WCHAR *nameW; + HANDLE file; if ((GetVersion() & 0x80000000) && IsBadStringPtrA(filename, -1)) return INVALID_HANDLE_VALUE; - if (!(nameW = FILE_name_AtoW( filename, FALSE ))) return INVALID_HANDLE_VALUE; - return CreateFileW( nameW, access, sharing, sa, creation, attributes, template ); + if (!(nameW = FILE_name_AtoW( filename, TRUE ))) return INVALID_HANDLE_VALUE; + file = CreateFileW( nameW, access, sharing, sa, creation, attributes, template ); + HeapFree( GetProcessHeap(), 0, nameW ); + return file; } /************************************************************************* -- 2.7.4
On 12/01/2017 11:42 AM, Alexandre Julliard wrote:
Zebediah Figura <z.figura12(a)gmail.com> writes:
We might call GetModuleHandle("krnl386.exe16") later, which will overwrite the static buffer.
I'd suggest fixing that instead, there's no reason to use A functions internally.
Good point; I completely overlooked this.
participants (2)
-
Alexandre Julliard -
Zebediah Figura