diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-01-26 19:41:23 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-01-26 19:41:23 +0100 |
commit | 1518f6ba33780193e7eab694a000ae05f4528359 (patch) | |
tree | da1c574a8493e549cceb37d46ad4e055ffd0fe0a /src/grab.c | |
parent | 2240d20332a68a2a3575698343f157f851d93179 (diff) |
Fix potential UTF-8 bugs
Diffstat (limited to 'src/grab.c')
-rw-r--r-- | src/grab.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -463,8 +463,10 @@ cmdH(struct sv sv, struct matches *ms, struct ops ops, size_t i, } prev = rm; - if (rm.rm_so == rm.rm_eo) - rm.rm_eo++; + if (rm.rm_so == rm.rm_eo) { + rune unused; + rm.rm_eo += u8tor_uc(&unused, sv.p + rm.rm_eo); + } rm = (regmatch_t){ .rm_so = rm.rm_eo, .rm_eo = sv.len, @@ -554,8 +556,10 @@ cmdX(struct sv sv, struct matches *ms, struct ops ops, size_t i, } prev = rm; - if (rm.rm_so == rm.rm_eo) - rm.rm_eo++; + if (rm.rm_so == rm.rm_eo) { + rune unused; + rm.rm_eo += u8tor_uc(&unused, sv.p + rm.rm_eo); + } rm = (regmatch_t){ .rm_so = rm.rm_eo, .rm_eo = sv.len, |