From b23c1064bcf85bd31871c7931ce18f36cc43be4c Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 21 Jan 2002 20:53:18 +0000 Subject: [PATCH] If g_convert fails, set bytes_written to 0 and close the iconv descriptor 2002-01-21 Jeffrey Stedfast * glib/gconvert.c (g_convert_with_fallback): If g_convert fails, set bytes_written to 0 and close the iconv descriptor that was opened a few lines above. On a successful return, calculate bytes_written to be outp - dest instead of outp - str. --- ChangeLog | 7 +++++++ ChangeLog.pre-2-0 | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ ChangeLog.pre-2-12 | 7 +++++++ ChangeLog.pre-2-2 | 7 +++++++ ChangeLog.pre-2-4 | 7 +++++++ ChangeLog.pre-2-6 | 7 +++++++ ChangeLog.pre-2-8 | 7 +++++++ glib/gconvert.c | 9 +++++++-- 9 files changed, 63 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9404970dd..88effe9c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-01-21 Jeffrey Stedfast + + * glib/gconvert.c (g_convert_with_fallback): If g_convert fails, + set bytes_written to 0 and close the iconv descriptor that was + opened a few lines above. On a successful return, calculate + bytes_written to be outp - dest instead of outp - str. + 2002-01-16 Sven Neumann * acinclude.m4 diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 9404970dd..88effe9c8 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,10 @@ +2002-01-21 Jeffrey Stedfast + + * glib/gconvert.c (g_convert_with_fallback): If g_convert fails, + set bytes_written to 0 and close the iconv descriptor that was + opened a few lines above. On a successful return, calculate + bytes_written to be outp - dest instead of outp - str. + 2002-01-16 Sven Neumann * acinclude.m4 diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9404970dd..88effe9c8 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2002-01-21 Jeffrey Stedfast + + * glib/gconvert.c (g_convert_with_fallback): If g_convert fails, + set bytes_written to 0 and close the iconv descriptor that was + opened a few lines above. On a successful return, calculate + bytes_written to be outp - dest instead of outp - str. + 2002-01-16 Sven Neumann * acinclude.m4 diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 9404970dd..88effe9c8 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,10 @@ +2002-01-21 Jeffrey Stedfast + + * glib/gconvert.c (g_convert_with_fallback): If g_convert fails, + set bytes_written to 0 and close the iconv descriptor that was + opened a few lines above. On a successful return, calculate + bytes_written to be outp - dest instead of outp - str. + 2002-01-16 Sven Neumann * acinclude.m4 diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 9404970dd..88effe9c8 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +2002-01-21 Jeffrey Stedfast + + * glib/gconvert.c (g_convert_with_fallback): If g_convert fails, + set bytes_written to 0 and close the iconv descriptor that was + opened a few lines above. On a successful return, calculate + bytes_written to be outp - dest instead of outp - str. + 2002-01-16 Sven Neumann * acinclude.m4 diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9404970dd..88effe9c8 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +2002-01-21 Jeffrey Stedfast + + * glib/gconvert.c (g_convert_with_fallback): If g_convert fails, + set bytes_written to 0 and close the iconv descriptor that was + opened a few lines above. On a successful return, calculate + bytes_written to be outp - dest instead of outp - str. + 2002-01-16 Sven Neumann * acinclude.m4 diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9404970dd..88effe9c8 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +2002-01-21 Jeffrey Stedfast + + * glib/gconvert.c (g_convert_with_fallback): If g_convert fails, + set bytes_written to 0 and close the iconv descriptor that was + opened a few lines above. On a successful return, calculate + bytes_written to be outp - dest instead of outp - str. + 2002-01-16 Sven Neumann * acinclude.m4 diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9404970dd..88effe9c8 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +2002-01-21 Jeffrey Stedfast + + * glib/gconvert.c (g_convert_with_fallback): If g_convert fails, + set bytes_written to 0 and close the iconv descriptor that was + opened a few lines above. On a successful return, calculate + bytes_written to be outp - dest instead of outp - str. + 2002-01-16 Sven Neumann * acinclude.m4 diff --git a/glib/gconvert.c b/glib/gconvert.c index 5ae83efb8..e8adccd00 100644 --- a/glib/gconvert.c +++ b/glib/gconvert.c @@ -497,7 +497,12 @@ g_convert_with_fallback (const gchar *str, utf8 = g_convert (str, len, "UTF-8", from_codeset, bytes_read, &inbytes_remaining, error); if (!utf8) - return NULL; + { + g_iconv_close (cd); + if (bytes_written) + *bytes_written = 0; + return NULL; + } /* Now the heart of the code. We loop through the UTF-8 string, and * whenever we hit an offending character, we form fallback, convert @@ -597,7 +602,7 @@ g_convert_with_fallback (const gchar *str, g_iconv_close (cd); if (bytes_written) - *bytes_written = outp - str; /* Doesn't include '\0' */ + *bytes_written = outp - dest; /* Doesn't include '\0' */ g_free (utf8);