From: Bruno Haible Date: Thu, 11 Sep 2003 16:40:32 +0000 (+0000) Subject: Avoid an abort() when the source file contains out-of-range Unicode characters. X-Git-Tag: v0.13~263 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e813d7359e224ccac8c988bda8ecd798b58214ea;p=thirdparty%2Fgettext.git Avoid an abort() when the source file contains out-of-range Unicode characters. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index a8787dcd2..150aacd42 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,8 @@ +2003-09-11 Bruno Haible + + * po-lex.c (mbfile_getc): Ignore the return value of u8_mbtouc(). + Reported by Jochen Hein . + 2003-09-09 Bruno Haible * read-properties.c (phase4_getuc): Cast line_number to 'unsigned long' diff --git a/gettext-tools/src/po-lex.c b/gettext-tools/src/po-lex.c index fa916b8c7..c0b7df2e1 100644 --- a/gettext-tools/src/po-lex.c +++ b/gettext-tools/src/po-lex.c @@ -511,8 +511,11 @@ incomplete multibyte sequence at end of line")); abort (); /* Convert it from UTF-8 to UCS-4. */ mbc->uc_valid = true; - if (u8_mbtouc (&mbc->uc, scratchbuf, outbytes) != outbytes) - abort (); + /* We ignore the return value of u8_mbtouc(): Usually it returns + outbytes, but if scratchbuf contains an out-of-range Unicode + character (> 0x10ffff), it can also return 1 and set mbc->uc + to 0xfffd. This is precisely what we need. */ + u8_mbtouc (&mbc->uc, scratchbuf, outbytes); break; } }