[PATCH] vi: correctly detect when a deletion empties the buffer
mike b
michallinuxstuff at gmail.com
Fri Nov 30 21:10:41 UTC 2018
Tested above patch, both issues seem to be fixed. Thanks for your help!
pt., 30 lis 2018 o 18:41 Ron Yorston <rmy at pobox.com> napisał(a):
> Michał Berger has reported two issues:
>
> - Repeatedly deleting and undoing the deletion of the last line
> results in characters being lost from the end of the line.
>
> - Deleting the bottom line twice then attempting to undo each of
> these deletions results in a segfault.
>
> The problem seems to be an incorrect test for whether the text buffer
> is empty.
>
> Reported-by: Michał Berger <michallinuxstuff at gmail.com>
> Signed-off-by: Ron Yorston <rmy at pobox.com>
> ---
> editors/vi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/editors/vi.c b/editors/vi.c
> index ee3c7feb2..271529404 100644
> --- a/editors/vi.c
> +++ b/editors/vi.c
> @@ -2364,7 +2364,7 @@ static void undo_push(char *src, unsigned int
> length, uint8_t u_type) // Add to
> // Allocate a new undo object
> if (u_type == UNDO_DEL || u_type == UNDO_DEL_CHAIN) {
> // For UNDO_DEL objects, save deleted text
> - if ((src + length) == end)
> + if ((text + length) == end)
> length--;
> // If this deletion empties text[], strip the newline.
> When the buffer becomes
> // zero-length, a newline is added back, which requires
> this to compensate.
> --
> 2.19.2
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20181130/b8d2a85b/attachment.html>
More information about the busybox
mailing list