Zhiyi Zhang : comctl32/taskdialog: Use dynamic buffer for taskdialog_get_label_size().

Alexandre Julliard julliard at winehq.org
Thu Jul 5 15:25:54 CDT 2018


Module: wine
Branch: master
Commit: 07d8d624598ad74933970063e29040c10b4675c1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=07d8d624598ad74933970063e29040c10b4675c1

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Tue Jun 26 11:35:24 2018 +0800

comctl32/taskdialog: Use dynamic buffer for taskdialog_get_label_size().

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 33fb578..5625f2b 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)




More information about the wine-cvs mailing list