Ticket #2484 (closed defect: fixed)
segv after codepage change
Reported by: | gotar | Owned by: | angel_il |
---|---|---|---|
Priority: | critical | Milestone: | 4.8.0-pre1 |
Component: | mcedit | Version: | 4.7.5 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | Votes for changeset: | committed-master |
Description
- mcedit file (with some 8-bit encoding, like latin2)
- type in some non-ascii letters (e.g. polish ąłśźż do harm while ćęńó are safe)
- change encoding to UTF-8 (alt-e, c)
- move cursor through these specified letters.
What seems weird is that not every non-7-bit letter causes segfault. Above ąłśźż are b1 b3 b6 bf bc in hex, while ćęńó are e6 ea f1 f3.
Moreover: consider ąłśóćźżłąśśą string - after switching to UTF-8 editor shows 10 dots (..........) while there was 12 letters. Having cursor at EOL left arrow moves it 3 cells left, next keypress does the same, third moves properly 1 cell, fourth breaks mcedit.
Apparently it tries to interpret bytes as unicode and seems to miss some sanity tests.
Change History
comment:1 Changed 14 years ago by angel_il
- Status changed from new to accepted
- Owner set to angel_il
comment:2 Changed 14 years ago by angel_il
try this patch
diff --git a/src/editor/edit.c b/src/editor/edit.c index 494f015..ec7a922 100644 --- a/src/editor/edit.c +++ b/src/editor/edit.c @@ -1852,8 +1852,13 @@ edit_get_prev_utf (WEdit * edit, long byte_index, int *char_width) if (str != buf) str = g_utf8_find_prev_char (buf, str); - res = g_utf8_get_char_validated (str, -1); - + if (str != NULL) + res = g_utf8_get_char_validated (str, -1); + else + { + *char_width = 0; + return 0; + } if (res < 0) { ch = *str;
comment:3 Changed 14 years ago by angel_il
every non-7-bit letter causes segfault
this my bug... i'm foget test 'str' on NULL before call 'g_utf8_get_char_validated'
comment:4 Changed 14 years ago by angel_il
- severity changed from no branch to on review
branch: 2484_editor_get_prev_utf8_fix
changeset: http://www.midnight-commander.org/changeset/2484_editor_get_prev_utf8_fix
please review
PS: i think is "stable candidate"...
comment:5 Changed 14 years ago by andrew_b
- Keywords stable-candidate added
- Votes for changeset set to andrew_b
- Milestone changed from 4.8 to 4.8.0-pre1
comment:6 Changed 14 years ago by slavazanko
- Votes for changeset changed from andrew_b to andrew_b slavazanko
- severity changed from on review to approved
comment:7 Changed 14 years ago by angel_il
- Votes for changeset changed from andrew_b slavazanko to committed-master
- severity changed from approved to merged
comment:8 Changed 14 years ago by angel_il
- Keywords stable-candidate removed
- Status changed from accepted to testing
- Resolution set to fixed
cherry-picked: 4.7.0-stable (028c8dd12259a252a43ad2fa09a2f38a4f4cf718)
cherry-picked: 4.7.5-stable (9ff73b6d23f0f8b47d0dcbcffab0f64eeb99d3bf)
comment:9 Changed 14 years ago by angel_il
- Status changed from testing to closed
cherry-picked: 4.7.0-stable (9258fa658d0f3da410493801b08aa164a78327b0)
cherry-picked: 4.7.5-stable (3b7477aae63360fc42bd1c5f831319cb654290a0)