vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 23dec2ca160bea4a3e5a9c383017200e5e0197d9
parent fece993997442bc4d0b85a3337719532e98785dc
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed,  8 Feb 2017 19:36:08 +0100

vis: make `ga` and `g8` more robust

Fixes CID 141179

Diffstat:
Mmain.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c @@ -2040,7 +2040,10 @@ static const char *unicode_info(Vis *vis, const char *keys, const Arg *arg) { mbstate_t ps = { 0 }; Iterator it = text_iterator_get(txt, start); for (size_t pos = start; it.pos < end; pos = it.pos) { - text_iterator_codepoint_next(&it, NULL); + if (!text_iterator_codepoint_next(&it, NULL)) { + vis_info_show(vis, "Failed to parse code point"); + goto err; + } size_t len = it.pos - pos; wchar_t wc = 0xFFFD; size_t res = mbrtowc(&wc, codepoint, len, &ps); @@ -2061,6 +2064,7 @@ static const char *unicode_info(Vis *vis, const char *keys, const Arg *arg) { codepoint += len; } vis_info_show(vis, "%s", buffer_content0(&info)); +err: free(grapheme); buffer_release(&info); return keys;