summaryrefslogtreecommitdiffstats
path: root/text.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-01-01 12:53:45 +0100
committerMattias Andrée <maandree@kth.se>2022-01-01 12:53:45 +0100
commit70f261a24c2c0827827cf226f77c774136489cc5 (patch)
treefb7c85e5ccbbcb773ee25af8ff66afa90780369b /text.c
parentValidate UTF-8 encoding and check for long lines (diff)
downloadmakel-70f261a24c2c0827827cf226f77c774136489cc5.tar.gz
makel-70f261a24c2c0827827cf226f77c774136489cc5.tar.bz2
makel-70f261a24c2c0827827cf226f77c774136489cc5.tar.xz
Fix replacement character insertion for invalid UTF-8
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'text.c')
-rw-r--r--text.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/text.c b/text.c
index e5498eb..0cb69e6 100644
--- a/text.c
+++ b/text.c
@@ -115,7 +115,8 @@ check_utf8_encoding(struct line *line)
&line->data[off + r],
line->len - off - r);
memcpy(&line->data[off], invalid_codepoint_encoding, ELEMSOF(invalid_codepoint_encoding));
- line->len = line->len - r + ELEMSOF(invalid_codepoint_encoding);
+ line->len -= r;
+ line->len += r = ELEMSOF(invalid_codepoint_encoding);
}
}
}