From 807afdadb8a94f3192b61a31e98755eab4e7052d Mon Sep 17 00:00:00 2001 From: Ivan Baravy Date: Wed, 23 Jun 2021 10:07:36 +0000 Subject: [PATCH] kernel: Fix memory corruption of clipboard data. There were a few off-by-one errors in window size calculation. As a result, winmap update code corrupted clipboard structures. git-svn-id: svn://kolibrios.org@8928 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/gui/mouse.inc | 2 ++ kernel/trunk/gui/window.inc | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/trunk/gui/mouse.inc b/kernel/trunk/gui/mouse.inc index 8dc359fe26..68590dd102 100644 --- a/kernel/trunk/gui/mouse.inc +++ b/kernel/trunk/gui/mouse.inc @@ -371,6 +371,7 @@ mouse._.move_handler: cmp eax, [_display.width] jl @f sub eax, [_display.width] + inc eax sub [mouse.active_sys_window.new_box.left], eax @@: mov eax, [mouse.active_sys_window.new_box.top] @@ -383,6 +384,7 @@ mouse._.move_handler: cmp eax, [_display.height] jl .call_window_handler sub eax, [_display.height] + inc eax sub [mouse.active_sys_window.new_box.top], eax jmp .call_window_handler diff --git a/kernel/trunk/gui/window.inc b/kernel/trunk/gui/window.inc index 5ee563b0dd..6b1e7e19b0 100644 --- a/kernel/trunk/gui/window.inc +++ b/kernel/trunk/gui/window.inc @@ -1686,7 +1686,8 @@ align 4 align 4 .fix_width_high: mov ecx, esi - mov [edi + WDATA.box.width], esi + dec ecx + mov [edi + WDATA.box.width], ecx jmp .check_left ;-------------------------------------- align 4 @@ -1699,13 +1700,15 @@ align 4 .fix_left_high: mov eax, esi sub eax, ecx + dec eax mov [edi + WDATA.box.left], eax jmp .check_height ;-------------------------------------- align 4 .fix_height_high: mov edx, esi - mov [edi + WDATA.box.height], esi + dec edx + mov [edi + WDATA.box.height], edx jmp .check_top ;-------------------------------------- align 4 @@ -1718,6 +1721,7 @@ align 4 .fix_top_high: mov ebx, esi sub ebx, edx + dec ebx mov [edi + WDATA.box.top], ebx jmp .exit ;------------------------------------------------------------------------------