aboutsummaryrefslogtreecommitdiff
path: root/src/grab.c
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-01-26 19:41:23 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-01-26 19:41:23 +0100
commit1518f6ba33780193e7eab694a000ae05f4528359 (patch)
treeda1c574a8493e549cceb37d46ad4e055ffd0fe0a /src/grab.c
parent2240d20332a68a2a3575698343f157f851d93179 (diff)
Fix potential UTF-8 bugs
Diffstat (limited to 'src/grab.c')
-rw-r--r--src/grab.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/grab.c b/src/grab.c
index 13a6e83..56d0442 100644
--- a/src/grab.c
+++ b/src/grab.c
@@ -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,