Skip to content

Commit ecec635

Browse files
committed
Cope with truncated utf8 input
1 parent 53348c5 commit ecec635

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libespeak-ng/translate.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,13 @@ int utf8_in2(int *c, const char *buf, int backwards)
301301

302302
c1 &= mask[n_bytes];
303303
for (ix = 0; ix < n_bytes; ix++)
304+
{
305+
if (!*buf)
306+
/* Oops, truncated */
307+
break;
304308
c1 = (c1 << 6) + (*buf++ & 0x3f);
309+
}
310+
n_bytes = ix;
305311
}
306312
*c = c1;
307313
return n_bytes+1;

0 commit comments

Comments
 (0)