mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Ticket #256 (segfault in backward_word)
fixed segfault in backward_word (widget.c) ... The for loop, whose purpose is to remove exactly 1 character (hence I don't get why it's a loop, but nevermind) was not UTF8-ready. So if the character preceding the cursor was an accented one, it jumped to the middle of the UTF-8 sequence, causing the rest of the stuff go unpredictable. Although it *should* never happen (which, as we all know, does not equal to "never happens"), in this case "p" simply jumped over "in->buffer". The function has a "p != in->buffer" check three times, it might it more robust if you replaced that with "p >= in->buffer". This should prevent the segfault, and just stay with a slightly buggy but otherwise harmless alt-backspace behavior, should there be any UTF-8 or similar bugs left. This change is not included in my patch. Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
This commit is contained in:
parent
daac0e5a67
commit
ecee0cd4b9
@ -1490,7 +1490,7 @@ backward_word (WInput *in)
|
||||
for (
|
||||
p = in->buffer + str_offset_to_pos (in->buffer, in->point);
|
||||
(p != in->buffer) && (p[0] == '\0');
|
||||
p-- , in->point--
|
||||
str_cprev_char (&p), in->point--
|
||||
);
|
||||
|
||||
while (p != in->buffer) {
|
||||
|
Loading…
Reference in New Issue
Block a user