[PATCH v2 1/3] comctl32/taskdialog: Use dynamic buffer for taskdialog_get_label_size().

Zhiyi Zhang zzhang at codeweavers.com
Mon Jun 25 22:35:24 CDT 2018


Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
 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 33fb578910..5625f2bc24 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)
-- 
2.17.1





More information about the wine-devel mailing list