Skip to content

Commit

Permalink
Merge pull request #25 from chansen/master
Browse files Browse the repository at this point in the history
Validate continuations in the incremental UTF-X decoder
  • Loading branch information
dankogai committed Oct 21, 2014
2 parents b4d116b + 07ee44a commit 3e9fd0c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Encode.xs
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,14 @@ process_utf8(pTHX_ SV* dst, U8* s, U8* e, SV *check_sv,
if (UTF8_IS_START(*s)) {
U8 skip = UTF8SKIP(s);
if ((s + skip) > e) {
/* Partial character */
/* XXX could check that rest of bytes are UTF8_IS_CONTINUATION(ch) */
if (stop_at_partial || (check & ENCODE_STOP_AT_PARTIAL))
if (stop_at_partial || (check & ENCODE_STOP_AT_PARTIAL)) {
const U8 *p = s + 1;
for (; p < e; p++) {
if (!UTF8_IS_CONTINUATION(*p))
goto malformed_byte;
}
break;
}

goto malformed_byte;
}
Expand Down

0 comments on commit 3e9fd0c

Please sign in to comment.