[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] vi: correctly detect when a deletion empties the buffer
From:       mike b <michallinuxstuff () gmail ! com>
Date:       2018-11-30 21:10:41
Message-ID: CACosJgyvD2sqoNw=-JXWn5ryhNpPVkzNGRZr+NF2OB1_M4JUyQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Tested above patch, both issues seem to be fixed. Thanks for your help!

pt., 30 lis 2018 o 18:41 Ron Yorston <rmy@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@gmail.com>
> Signed-off-by: Ron Yorston <rmy@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
>
>

[Attachment #5 (text/html)]

<div dir="ltr">Tested above patch, both issues seem to be fixed. Thanks for your \
help!<br></div><br><div class="gmail_quote"><div dir="ltr">pt., 30 lis 2018 o 18:41  \
Ron Yorston &lt;<a href="mailto:rmy@pobox.com">rmy@pobox.com</a>&gt; \
napisał(a):<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">Michał Berger has reported two \
issues:<br> <br>
- Repeatedly deleting and undoing the deletion of the last line<br>
   results in characters being lost from the end of the line.<br>
<br>
- Deleting the bottom line twice then attempting to undo each of<br>
   these deletions results in a segfault.<br>
<br>
The problem seems to be an incorrect test for whether the text buffer<br>
is empty.<br>
<br>
Reported-by: Michał Berger &lt;<a href="mailto:michallinuxstuff@gmail.com" \
                target="_blank">michallinuxstuff@gmail.com</a>&gt;<br>
Signed-off-by: Ron Yorston &lt;<a href="mailto:rmy@pobox.com" \
                target="_blank">rmy@pobox.com</a>&gt;<br>
---<br>
  editors/vi.c | 2 +-<br>
  1 file changed, 1 insertion(+), 1 deletion(-)<br>
<br>
diff --git a/editors/vi.c b/editors/vi.c<br>
index ee3c7feb2..271529404 100644<br>
--- a/editors/vi.c<br>
+++ b/editors/vi.c<br>
@@ -2364,7 +2364,7 @@ static void undo_push(char *src, unsigned int length, uint8_t \
u_type)        // Add to<br>  // Allocate a new undo object<br>
            if (u_type == UNDO_DEL || u_type == UNDO_DEL_CHAIN) {<br>
                        // For UNDO_DEL objects, save deleted text<br>
-                       if ((src + length) == end)<br>
+                       if ((text + length) == end)<br>
                                    length--;<br>
                        // If this deletion empties text[], strip the newline. When \
                the buffer becomes<br>
                        // zero-length, a newline is added back, which requires this \
                to compensate.<br>
-- <br>
2.19.2<br>
<br>
</blockquote></div>



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic