[evolution-data-server] Grow the output buffer as needed when flushing iconv
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Grow the output buffer as needed when flushing iconv
- Date: Tue, 20 Dec 2011 01:09:15 +0000 (UTC)
commit a066ce7091e3aad07dd093038b7fdb9f03cdb6ec
Author: Jeffrey Stedfast <fejj gnome org>
Date: Mon Dec 19 20:08:42 2011 -0500
Grow the output buffer as needed when flushing iconv
camel/camel-mime-filter-charset.c | 10 +++++++++-
camel/camel-mime-utils.c | 11 ++++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/camel/camel-mime-filter-charset.c b/camel/camel-mime-filter-charset.c
index ec5daa5..8dd167c 100644
--- a/camel/camel-mime-filter-charset.c
+++ b/camel/camel-mime-filter-charset.c
@@ -128,7 +128,15 @@ mime_filter_charset_complete (CamelMimeFilter *mime_filter,
}
/* flush the iconv conversion */
- camel_iconv (priv->ic, NULL, NULL, &outbuf, &outleft);
+ while (camel_iconv (priv->ic, NULL, NULL, &outbuf, &outleft) == (gsize) -1) {
+ if (errno != E2BIG)
+ break;
+
+ converted = outbuf - mime_filter->outbuf;
+ camel_mime_filter_set_size (mime_filter, mime_filter->outsize + 16, TRUE);
+ outbuf = mime_filter->outbuf + converted;
+ outleft = mime_filter->outsize - converted;
+ }
*out = mime_filter->outbuf;
*outlen = mime_filter->outsize - outleft;
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 543631f..86de327 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -878,7 +878,16 @@ camel_iconv_strndup (iconv_t cd,
*/
/* flush the iconv conversion */
- iconv (cd, NULL, NULL, &outbuf, &outleft);
+ while (iconv (cd, NULL, NULL, &outbuf, &outleft) == (gsize) -1) {
+ if (errno != E2BIG)
+ break;
+
+ outlen += 16;
+ converted = outbuf - out;
+ out = g_realloc (out, outlen + 4);
+ outleft = outlen - converted;
+ outbuf = out + converted;
+ }
/* Note: not all charsets can be nul-terminated with a single
* nul byte. UCS2, for example, needs 2 nul bytes and UCS4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]