X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Funiconv%2Fu-conv-to-enc.h;h=68ff81484b528b6b030d38a02ccff49a189863ec;hb=b792aeb401b00124b3c27c9f1d850d3312e7b849;hp=b69a2b7f52de80de6a2089e818e45b3fb5b50980;hpb=b2a72dabdfa8bd663f0d5e61706b82953390d4fb;p=gnulib.git diff --git a/lib/uniconv/u-conv-to-enc.h b/lib/uniconv/u-conv-to-enc.h index b69a2b7f5..68ff81484 100644 --- a/lib/uniconv/u-conv-to-enc.h +++ b/lib/uniconv/u-conv-to-enc.h @@ -106,7 +106,7 @@ FUNC (const char *tocode, iunit = 0; i8 = 0; - while (iunit < srclen) + while (iunit < srclen && i8 < utf8_srclen) { int countunit; int count8; @@ -120,6 +120,17 @@ FUNC (const char *tocode, iunit += countunit; i8 += count8; } + /* Check that utf8_src has been traversed entirely. */ + if (i8 < utf8_srclen) + abort (); + /* Check that src has been traversed entirely, except possibly for an + incomplete sequence of units at the end. */ + if (iunit < srclen) + { + offsets[iunit] = *lengthp; + if (!(U_MBLEN (src + iunit, srclen - iunit) < 0)) + abort (); + } free (scaled_offsets); } if (utf8_src != tmpbuf)