fix crash when copy\paste

git-svn-id: svn://kolibrios.org@7404 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
0CodErr 2018-09-22 07:58:01 +00:00
parent fcd44f1ce5
commit fa3e0cb007

View File

@ -364,30 +364,20 @@ edit_box_key.end:
;---------------------------------------- ;----------------------------------------
StrInsert: StrInsert:
; SizeOf(TmpBuf) >= StrLen(Src) + StrLen(Dst) + 1 ; SizeOf(TmpBuf) >= StrLen(Src) + StrLen(Dst) + 1
Dst equ [esp + 20] ; - destination buffer Dst equ [esp + 16] ; - destination buffer
Src equ [esp + 16] ; - source to insert from Src equ [esp + 12] ; - source to insert from
Pos equ [esp + 12] ; - position for insert Pos equ [esp + 8] ; - position for insert
DstMax equ [esp + 8] ; - maximum Dst length(exclude terminating null) DstMax equ [esp + 4] ; - maximum Dst length(exclude terminating null)
TmpBuf equ [esp + 4] ; - temporary buffer SrcCount equ [esp - 4]
xor edx, edx DstCount equ [esp - 8]
mov esi, Dst TmpBuf equ [esp - 12] ; - temporary buffer
mov edi, TmpBuf
mov ecx, Pos
add edx, ecx
rep movsb
mov edi, Src mov edi, Src
mov ecx, -1 mov ecx, -1
xor eax, eax xor eax, eax
repne scasb repne scasb
mov eax, -2 mov eax, -2
sub eax, ecx sub eax, ecx
add edx, eax mov SrcCount, eax
mov esi, Src
mov edi, TmpBuf
add edi, Pos
mov ecx, eax
rep movsb
mov ebx, edi
mov edi, Dst mov edi, Dst
add edi, Pos add edi, Pos
mov ecx, -1 mov ecx, -1
@ -396,12 +386,28 @@ TmpBuf equ [esp + 4] ; - temporary buffer
mov eax, -2 mov eax, -2
sub eax, ecx sub eax, ecx
inc eax inc eax
add edx, eax mov DstCount, eax
mov edi, ebx mov ecx, eax
add ecx, SrcCount
add ecx, Pos
mcall SF_SYS_MISC,SSF_MEM_ALLOC
mov TmpBuf, eax
mov esi, Dst
mov edi, TmpBuf
mov ecx, Pos
mov edx, ecx
rep movsb
mov esi, Src
mov edi, TmpBuf
add edi, Pos
mov ecx, SrcCount
add edx, ecx
rep movsb
mov esi, Pos mov esi, Pos
add esi, Dst add esi, Dst
mov ecx, eax mov ecx, DstCount
rep movsb add edx, ecx
rep movsb
mov esi, TmpBuf mov esi, TmpBuf
mov edi, Dst mov edi, Dst
; ecx = MIN(edx, DstSize) ; ecx = MIN(edx, DstSize)
@ -412,13 +418,17 @@ TmpBuf equ [esp + 4] ; - temporary buffer
and ecx, DstMax and ecx, DstMax
add ecx, edx add ecx, edx
mov eax, ecx ; return total length mov eax, ecx ; return total length
rep movsb rep movsb
ret 20 mov ecx, TmpBuf
mcall SF_SYS_MISC,SSF_MEM_FREE
ret 16
restore Dst restore Dst
restore Src restore Src
restore Pos restore Pos
restore DstSize restore DstSize
restore TmpBuf restore TmpBuf
restore SrcCount
restore DstCount
;---------------------------------------- ;----------------------------------------
edit_box_key.ctrl_x: edit_box_key.ctrl_x:
test word ed_flags,ed_shift_on test word ed_flags,ed_shift_on
@ -529,22 +539,13 @@ edit_box_key.ctrl_v:
add esi,3*4 add esi,3*4
push eax edi push eax edi
;---------------------------------------; ;---------------------------------------;
mov ed_size,ecx mov ed_size,ecx
inc ecx
mcall SF_SYS_MISC,SSF_MEM_ALLOC
push eax ; save mem pointer
mov edx, ed_max
push dword ed_text ; Dst push dword ed_text ; Dst
push esi ; Src push esi ; Src
push dword ed_pos ; Pos in Dst push dword ed_pos ; Pos in Dst
push edx ; DstMax push dword ed_max ; DstMax
push eax ; TmpBuf call StrInsert
call StrInsert
pop eax ; restore mem pointer
mcall SF_SYS_MISC,SSF_MEM_FREE
;---------------------------------------; ;---------------------------------------;
; mov edi,ed_text ; mov edi,ed_text
; cld ; cld