From 9443bf38d23da25448efa6f72d1751b0add4014a Mon Sep 17 00:00:00 2001 From: "Marat Zakiyanov (Mario79)" Date: Sun, 9 Feb 2014 18:17:39 +0000 Subject: [PATCH] Tinypad - fix for crash when "paste" from clipboard in some cases. git-svn-id: svn://kolibrios.org@4566 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../develop/tinypad/trunk/data/tp-udata.inc | 1 + programs/develop/tinypad/trunk/tinypad.asm | 1 - .../develop/tinypad/trunk/tp-clipboard.asm | 21 ++++++------------- programs/develop/tinypad/trunk/tp-key.asm | 20 ++++++++++++++++-- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/programs/develop/tinypad/trunk/data/tp-udata.inc b/programs/develop/tinypad/trunk/data/tp-udata.inc index c6486c08f8..c80af05ab1 100644 --- a/programs/develop/tinypad/trunk/data/tp-udata.inc +++ b/programs/develop/tinypad/trunk/data/tp-udata.inc @@ -108,6 +108,7 @@ exit_tab_num dd ? temp_buf dd ? copy_buf dd ? clipboard_buf dd ? +size_of_moving_area dd ? label color_tbl dword .text dd ? diff --git a/programs/develop/tinypad/trunk/tinypad.asm b/programs/develop/tinypad/trunk/tinypad.asm index 9f47827142..4be4fa5210 100644 --- a/programs/develop/tinypad/trunk/tinypad.asm +++ b/programs/develop/tinypad/trunk/tinypad.asm @@ -41,7 +41,6 @@ APP_VERSION equ 'SVN (4.0.8)' TRUE = 1 FALSE = 0 -;include 'debug.inc' ;define __DEBUG__ 1 ;define __DEBUG_LEVEL__ 1 ;include '../../../debug-fdo.inc' diff --git a/programs/develop/tinypad/trunk/tp-clipboard.asm b/programs/develop/tinypad/trunk/tp-clipboard.asm index 7eb32e7650..a90b797cc1 100644 --- a/programs/develop/tinypad/trunk/tp-clipboard.asm +++ b/programs/develop/tinypad/trunk/tp-clipboard.asm @@ -96,14 +96,14 @@ get_from_clipboard: .yes_valid_text: call know_number_line_breaks mov [copy_count],ebx - +; correction of erroneous buffer size mov eax,[clipboard_buf] sub esi,eax mov [eax],esi - +; multiple by 6 shl ebx,1 lea ebx,[ebx*3] - +; calculating a desired size mov eax,[clipboard_buf] mov eax,[eax] sub eax,4*3 @@ -249,7 +249,7 @@ know_number_line_breaks: lodsb test al,al - jz .end_of_data_1 + jz .end_of_data cmp al,0x0d je .check_0x0a @@ -281,17 +281,8 @@ know_number_line_breaks: dec ecx jnz @b ;-------------------------------------- -.end_of_data_1: - cmp [esi-2],byte 0x0d - je .end_of_data - - cmp [esi-2],byte 0x0a - je .end_of_data - - inc ebx - inc esi -;-------------------------------------- .end_of_data: - inc ebx + add ebx,2 + inc esi ret ;----------------------------------------------------------------------------- \ No newline at end of file diff --git a/programs/develop/tinypad/trunk/tp-key.asm b/programs/develop/tinypad/trunk/tp-key.asm index ac1a68a6d8..ac6c18407c 100644 --- a/programs/develop/tinypad/trunk/tp-key.asm +++ b/programs/develop/tinypad/trunk/tp-key.asm @@ -610,7 +610,12 @@ proc key.ctrl_v add [esp],eax add esi,eax mov ecx,[copy_size] + mov edi,[copy_count] + test edi,edi + dec edi + jnz @f sub ecx,sizeof.EDITOR_LINE_DATA +@@: mov edi,[cur_editor.Lines] add edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4] dec edi @@ -621,6 +626,7 @@ proc key.ctrl_v add ecx,[cur_editor.Caret.X] neg ecx lea ecx,[esi+ecx+1] + mov [size_of_moving_area],ecx std rep movsb @@ -655,11 +661,22 @@ proc key.ctrl_v pop ecx sub ecx,ebx + ja @f + + pusha + mov esi,edi + sub edi,sizeof.EDITOR_LINE_DATA + mov ecx,[size_of_moving_area] + cld + rep movsb + popa + jmp .save_cur_editor_values +@@: add [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size],ecx call .check_columns mov ecx,eax rep movsb - +.save_cur_editor_values: mov [cur_editor.Caret.X],eax mov [cur_editor.SelStart.X],eax mov eax,[copy_count] @@ -716,7 +733,6 @@ proc key.ctrl_v @@: pop eax ret endp - ;----------------------------------------------------------------------------- proc key.ctrl_d ;///// INSERT SEPARATOR ////////////////////////////////////// ;-----------------------------------------------------------------------------