diff options
author | Ron Yorston <rmy@pobox.com> | 2018-12-03 10:07:58 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-03 10:07:58 +0100 |
commit | d08206dce1291f512d7de9037d9ef1ffbf705cac (patch) | |
tree | 373e132573908561f985206eb143a7cebb689f99 | |
parent | b7330460693f12585c7a6246f0dfafd8742af05a (diff) | |
download | busybox-w32-d08206dce1291f512d7de9037d9ef1ffbf705cac.tar.gz busybox-w32-d08206dce1291f512d7de9037d9ef1ffbf705cac.tar.bz2 busybox-w32-d08206dce1291f512d7de9037d9ef1ffbf705cac.zip |
vi: correctly detect when a deletion empties the buffer
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>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/vi.c | 2 |
1 files changed, 1 insertions, 1 deletions
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 | |||
2364 | // Allocate a new undo object | 2364 | // Allocate a new undo object |
2365 | if (u_type == UNDO_DEL || u_type == UNDO_DEL_CHAIN) { | 2365 | if (u_type == UNDO_DEL || u_type == UNDO_DEL_CHAIN) { |
2366 | // For UNDO_DEL objects, save deleted text | 2366 | // For UNDO_DEL objects, save deleted text |
2367 | if ((src + length) == end) | 2367 | if ((text + length) == end) |
2368 | length--; | 2368 | length--; |
2369 | // If this deletion empties text[], strip the newline. When the buffer becomes | 2369 | // If this deletion empties text[], strip the newline. When the buffer becomes |
2370 | // zero-length, a newline is added back, which requires this to compensate. | 2370 | // zero-length, a newline is added back, which requires this to compensate. |