Skip to content

Commit 05eb966

Browse files
committed
Fix off-by-one in utf-8 encoding
1 parent 98e6d9c commit 05eb966

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ target/
1717
*.o
1818
*.a
1919
*.tar.gz
20+
/a.out
21+
/test.c

jt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ unsigned long utf_tag[4] = { 0x00, 0xc0, 0xe0, 0xf0 };
219219

220220
void encode_u_escaped(char **in, char **out) {
221221
unsigned long p = read_code_point(in);
222-
int len = (p < 0x80) ? 1 : ((p < 0x800) ? 2 : ((p < 0x1000) ? 3 : 4));
222+
int len = (p < 0x80) ? 1 : ((p < 0x800) ? 2 : ((p < 0x10000) ? 3 : 4));
223223
*out += len;
224224
switch (len) {
225225
case 4: *--(*out) = ((p | 0x80) & 0xbf); p >>= 6;

0 commit comments

Comments
 (0)