on master help sign in
A minimal fix for the regression introduced in the previous commit

The refactoring in that commit was performed incorrectly, such that it would no longer detect as invalid an incomplete series of continuation bytes at the end of a string.

commite7c230b57eec38ccd08caf36105e8d46d578bb4e authorBryan O'Sullivan <bos@serpentine.com> dateSun 29 Dec 2013, 22:50 (13 years ago) parentaca0971
1 file changed+6−1
cbits/cbits.c+6−1
cbits/cbits.c+6−1
@@ -198,5 +198,10 @@ _hs_text_decode_utf8(uint16_t *dest, size_t *destoff,
198198{
199199 uint32_t codepoint;
200200 uint32_t state = UTF8_ACCEPT;
201− return _hs_text_decode_utf8_state(dest, destoff, src, srcend, &codepoint, &state);
201+ uint8_t const *ret = _hs_text_decode_utf8_state(dest, destoff, src, srcend,
202+ &codepoint, &state);
203+ /* Back up if we have an incomplete encoding */
204+ if (state != UTF8_ACCEPT && state != UTF8_REJECT)
205+ ret -= 1;
206+ return ret;
202207}