[gmime] Apply the same iconv flush fix to the charset filter



commit bcad21ca7ebe17644faa89471b43a5d4d11701eb
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Thu Dec 15 22:22:02 2011 -0500

    Apply the same iconv flush fix to the charset filter
    
    2011-12-15  Jeffrey Stedfast  <fejj gnome org>
    
    	* gmime/gmime-filter-charset.c (flter_complete): Same as
    	charset_convert().

 ChangeLog                    |    3 +++
 gmime/gmime-filter-charset.c |   10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 18a78f4..7f6891d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2011-12-15  Jeffrey Stedfast  <fejj gnome org>
 
+	* gmime/gmime-filter-charset.c (flter_complete): Same as
+	charset_convert().
+
 	* gmime/gmime-utils.c (charset_convert): Make sure the output
 	buffer is large enough when flushing the conversion descriptor.
 
diff --git a/gmime/gmime-filter-charset.c b/gmime/gmime-filter-charset.c
index efc8f7a..77695e3 100644
--- a/gmime/gmime-filter-charset.c
+++ b/gmime/gmime-filter-charset.c
@@ -258,7 +258,15 @@ filter_complete (GMimeFilter *filter, char *in, size_t len, size_t prespace,
 	}
 	
 	/* flush the iconv conversion */
-	iconv (charset->cd, NULL, NULL, &outbuf, &outleft);
+	while (iconv (charset->cd, NULL, NULL, &outbuf, &outleft) == (size_t) -1) {
+		if (errno != E2BIG)
+			break;
+		
+		converted = outbuf - filter->outbuf;
+		g_mime_filter_set_size (filter, filter->outsize + 16, TRUE);
+		outbuf = filter->outbuf + converted;
+		outleft = filter->outsize - converted;
+	}
 	
 	*out = filter->outbuf;
 	*outlen = outbuf - filter->outbuf;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]