From b6204639ba864231bd14164363613963a9696278 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Tue, 29 Nov 2022 12:17:11 +0100 Subject: [PATCH] gdi32: NULL terminate output string in CreateDCW. --- dlls/gdi32/dc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 6ec11650d27..44dd9b9373d 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -244,7 +244,7 @@ HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output, { return 0; } - else if (output && !(port = HeapAlloc( GetProcessHeap(), 0, output_str.Length ))) + else if (output && !(port = HeapAlloc( GetProcessHeap(), 0, output_str.Length + sizeof(WCHAR) ))) { ClosePrinter( hspool ); return 0; @@ -271,7 +271,10 @@ HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output, if (ret && hspool && (dc_attr = get_dc_attr( ret ))) { if (port) + { memcpy( port, output, output_str.Length ); + port[output_str.Length / sizeof(WCHAR)] = 0; + } dc_attr->hspool = HandleToULong( hspool ); dc_attr->output = (ULONG_PTR)port; }