[vte] [iso2022] Work around buggy iconv (#567064)



commit 78f9b61137028bd3b0c4b24c6b2169511b1d1e28
Author: Behdad Esfahbod <behdad behdad org>
Date:   Thu Apr 23 11:27:18 2009 -0400

    [iso2022] Work around buggy iconv (#567064)
    
    Seems like glibc's iconv is buggy, eating the ill sequence then
    returning EILSEQ.  This was causing crashes.  Work around it.
---
 src/iso2022.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/iso2022.c b/src/iso2022.c
index a42e596..d727cb4 100644
--- a/src/iso2022.c
+++ b/src/iso2022.c
@@ -1197,9 +1197,15 @@ process_cdata(struct _vte_iso2022_state *state, const guchar *cdata, gsize lengt
 								   &outbytes);
 					switch (i) {
 					case 0:
-						/* Nope, munge the input. */
-						inbuf++;
-						inbytes--;
+						/* iconv() may be buggy,
+						 * returning EILSEQ and
+						 * no remaining bytes.
+						 * Bug 567064 */
+						if (inbytes) {
+							/* Nope, munge the input. */
+							inbuf++;
+							inbytes--;
+						}
 						*outbuf++ = INVALID_CODEPOINT;
 						outbytes -= sizeof(gunichar);
 						break;



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