From: Pengpeng Dong Subject: [PATCH] conhost: Add the case where the divisor is 0. Message-Id: <65c3623c-6690-39ee-bf29-c9bf1093039c@uniontech.com> Date: Tue, 22 Sep 2020 13:32:45 +0800 From 7ec1db7cb9a1808f1c20041f32809cf2328cca9a Mon Sep 17 00:00:00 2001 From: Pengpeng Dong Date: Tue, 22 Sep 2020 13:26:23 +0800 Subject: [PATCH] conhost: Add the case where the divisor is 0. Signed-off-by: Pengpeng Dong --- programs/conhost/conhost.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index c0a0e08e6d..87676a9fdf 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -1991,6 +1991,7 @@ static NTSTATUS write_output( struct screen_buffer *screen_buffer, const struct char_info_t *dest; char *src; + entry_size = params->mode == CHAR_INFO_MODE_TEXTATTR ? sizeof(char_info_t) : sizeof(WCHAR); entry_cnt = (in_size - sizeof(*params)) / entry_size; @@ -2076,7 +2077,10 @@ static NTSTATUS write_output( struct screen_buffer *screen_buffer, const struct region->Left = x; region->Top = y; region->Right = min( x + width, screen_buffer->width ) - 1; - region->Bottom = min( y + entry_cnt / width, screen_buffer->height ) - 1; + if (width) + region->Bottom = min( y + entry_cnt / width, screen_buffer->height ) - 1; + else + region->Bottom = y + (x + i - 1) / screen_buffer->width; } else { -- 2.20.1