From: Timo Sirainen Date: Mon, 21 Jun 2010 20:17:58 +0000 (+0100) Subject: lib-charset: Don't assert-crash when iconv() skips lots of invalid input. X-Git-Tag: 2.0.rc1~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e312a1352e641e1c595ee25c6367bb008e9f7173;p=thirdparty%2Fdovecot%2Fcore.git lib-charset: Don't assert-crash when iconv() skips lots of invalid input. --HG-- branch : HEAD --- diff --git a/src/lib-charset/charset-iconv.c b/src/lib-charset/charset-iconv.c index ee3d31f26c..b0ca3ce8bd 100644 --- a/src/lib-charset/charset-iconv.c +++ b/src/lib-charset/charset-iconv.c @@ -131,7 +131,7 @@ charset_to_utf8(struct charset_translation *t, { bool dtcase = (t->flags & CHARSET_FLAG_DECOMP_TITLECASE) != 0; enum charset_result result; - size_t pos, used, size, prev_used = 0; + size_t pos, used, size, prev_pos = 0, prev_used = 0; bool ret; for (pos = 0;;) { @@ -151,7 +151,8 @@ charset_to_utf8(struct charset_translation *t, (void)buffer_append_space_unsafe(dest, size); buffer_set_used_size(dest, used); } else { - i_assert(dest->used != prev_used); + i_assert(dest->used != prev_used || pos != prev_pos); + prev_pos = pos; prev_used = dest->used; } }