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:
; SizeOf(TmpBuf) >= StrLen(Src) + StrLen(Dst) + 1
Dst equ [esp + 20] ; - destination buffer
Src equ [esp + 16] ; - source to insert from
Pos equ [esp + 12] ; - position for insert
DstMax equ [esp + 8] ; - maximum Dst length(exclude terminating null)
TmpBuf equ [esp + 4] ; - temporary buffer
xor edx, edx
mov esi, Dst
mov edi, TmpBuf
mov ecx, Pos
add edx, ecx
rep movsb
Dst equ [esp + 16] ; - destination buffer
Src equ [esp + 12] ; - source to insert from
Pos equ [esp + 8] ; - position for insert
DstMax equ [esp + 4] ; - maximum Dst length(exclude terminating null)
SrcCount equ [esp - 4]
DstCount equ [esp - 8]
TmpBuf equ [esp - 12] ; - temporary buffer
mov edi, Src
mov ecx, -1
xor eax, eax
repne scasb
mov eax, -2
sub eax, ecx
add edx, eax
mov esi, Src
mov edi, TmpBuf
add edi, Pos
mov ecx, eax
rep movsb
mov ebx, edi
mov SrcCount, eax
mov edi, Dst
add edi, Pos
mov ecx, -1
@ -396,11 +386,27 @@ TmpBuf equ [esp + 4] ; - temporary buffer
mov eax, -2
sub eax, ecx
inc eax
add edx, eax
mov edi, ebx
mov DstCount, eax
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
add esi, Dst
mov ecx, eax
mov ecx, DstCount
add edx, ecx
rep movsb
mov esi, TmpBuf
mov edi, Dst
@ -413,12 +419,16 @@ TmpBuf equ [esp + 4] ; - temporary buffer
add ecx, edx
mov eax, ecx ; return total length
rep movsb
ret 20
mov ecx, TmpBuf
mcall SF_SYS_MISC,SSF_MEM_FREE
ret 16
restore Dst
restore Src
restore Pos
restore DstSize
restore TmpBuf
restore SrcCount
restore DstCount
;----------------------------------------
edit_box_key.ctrl_x:
test word ed_flags,ed_shift_on
@ -530,21 +540,12 @@ edit_box_key.ctrl_v:
push eax edi
;---------------------------------------;
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 esi ; Src
push dword ed_pos ; Pos in Dst
push edx ; DstMax
push eax ; TmpBuf
push dword ed_max ; DstMax
call StrInsert
pop eax ; restore mem pointer
mcall SF_SYS_MISC,SSF_MEM_FREE
;---------------------------------------;
; mov edi,ed_text
; cld