In the old button layout algorithm, line count is added before adding button. This cause line count buffer overflow when the first button is very long.
This patch modify the algorithm to add button first before adjusting line count.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/comctl32/taskdialog.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index 1a5fad1609..33fb578910 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -506,16 +506,15 @@ static void taskdialog_layout(struct taskdialog_info *dialog_info) x = h_spacing; for (i = 0, line_count = 0; i < dialog_info->button_count; i++) { - if (x + button_layout_infos[i].width + h_spacing >= dialog_width) + button_layout_infos[i].line = line_count; + x += button_layout_infos[i].width + h_spacing; + line_widths[line_count] += button_layout_infos[i].width + h_spacing; + + if ((i + 1 < dialog_info->button_count) && (x + button_layout_infos[i + 1].width + h_spacing >= dialog_width)) { x = h_spacing; line_count++; } - - button_layout_infos[i].line = line_count; - - x += button_layout_infos[i].width + h_spacing; - line_widths[line_count] += button_layout_infos[i].width + h_spacing; } line_count++;