From 07d8d624598ad74933970063e29040c10b4675c1 Mon Sep 17 00:00:00 2001 From: Zhiyi Zhang Date: Tue, 26 Jun 2018 11:35:24 +0800 Subject: [PATCH] comctl32/taskdialog: Use dynamic buffer for taskdialog_get_label_size(). Signed-off-by: Zhiyi Zhang Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/taskdialog.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index 33fb5789103..5625f2bc241 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -235,7 +235,7 @@ static void taskdialog_get_label_size(struct taskdialog_info *dialog_info, HWND HFONT hfont, old_hfont; HDC hdc; RECT rect = {0}; - WCHAR text[1024]; + WCHAR *text; INT text_length; if (syslink) @@ -250,7 +250,15 @@ static void taskdialog_get_label_size(struct taskdialog_info *dialog_info, HWND style |= DT_LEFT; hfont = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0); - text_length = GetWindowTextW(hwnd, text, ARRAY_SIZE(text)); + text_length = GetWindowTextLengthW(hwnd); + text = Alloc((text_length + 1) * sizeof(WCHAR)); + if (!text) + { + size->cx = 0; + size->cy = 0; + return; + } + GetWindowTextW(hwnd, text, text_length + 1); hdc = GetDC(hwnd); old_hfont = SelectObject(hdc, hfont); rect.right = max_width; @@ -258,6 +266,7 @@ static void taskdialog_get_label_size(struct taskdialog_info *dialog_info, HWND size->cx = min(max_width, rect.right - rect.left); if (old_hfont) SelectObject(hdc, old_hfont); ReleaseDC(hwnd, hdc); + Free(text); } static ULONG_PTR taskdialog_get_standard_icon(LPCWSTR icon)