[gtksourceview/wip/uchardet: 2/2] BufferOutputStream: bug fix in guess_encoding_fallback()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/uchardet: 2/2] BufferOutputStream: bug fix in guess_encoding_fallback()
- Date: Thu, 26 Nov 2015 16:31:32 +0000 (UTC)
commit d4311113fe520930d8c275ead1782d20705ae04f
Author: Jehan <jehan girinstud io>
Date: Sat Sep 5 16:28:27 2015 +0200
BufferOutputStream: bug fix in guess_encoding_fallback()
If all try_convert() tests fails, we should return NULL, not the last
encoding we tried.
https://bugzilla.gnome.org/show_bug.cgi?id=669448
gtksourceview/gtksourcebufferoutputstream.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/gtksourcebufferoutputstream.c b/gtksourceview/gtksourcebufferoutputstream.c
index 200a16c..26a584c 100644
--- a/gtksourceview/gtksourcebufferoutputstream.c
+++ b/gtksourceview/gtksourcebufferoutputstream.c
@@ -390,6 +390,7 @@ guess_encoding_fallback (GtkSourceBufferOutputStream *stream,
gsize inbuf_size)
{
GCharsetConverter *conv = NULL;
+ gboolean success = FALSE;
if (stream->priv->encodings != NULL &&
stream->priv->encodings->next == NULL)
@@ -454,6 +455,7 @@ guess_encoding_fallback (GtkSourceBufferOutputStream *stream,
/* Try to convert */
if (try_convert (conv, inbuf, inbuf_size))
{
+ success = TRUE;
break;
}
}
@@ -463,6 +465,11 @@ guess_encoding_fallback (GtkSourceBufferOutputStream *stream,
g_converter_reset (G_CONVERTER (conv));
}
+ if (!success)
+ {
+ g_clear_object (&conv);
+ }
+
return conv;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]