[gedit] Fix possible memory leak



commit 9776527b66d7812914fb6fb0ba68529581421c7e
Author: Daniel Trebbien <dtrebbien gmail com>
Date:   Sat Feb 11 12:36:48 2012 -0500

    Fix possible memory leak
    
    If gedit_document_output_stream_write() is called and the ostream is not
    initialized, g_iconv_open() fails (so gedit_document_output_stream_write()
    returns -1), and gedit_document_output_stream_write() is called again,
    then the `charset_conv` that was created during the previous initialization
    attempt would be leaked.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=669898

 gedit/gedit-document-output-stream.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/gedit/gedit-document-output-stream.c b/gedit/gedit-document-output-stream.c
index 0143e83..4328da2 100644
--- a/gedit/gedit-document-output-stream.c
+++ b/gedit/gedit-document-output-stream.c
@@ -834,6 +834,7 @@ gedit_document_output_stream_write (GOutputStream            *stream,
 			g_set_error_literal (error, GEDIT_DOCUMENT_ERROR,
 			                     GEDIT_DOCUMENT_ERROR_ENCODING_AUTO_DETECTION_FAILED,
 			                     _("It is not possible to detect the encoding automatically"));
+
 			return -1;
 		}
 
@@ -865,6 +866,7 @@ gedit_document_output_stream_write (GOutputStream            *stream,
 				}
 
 				g_free (from_charset);
+				g_clear_object (&ostream->priv->charset_conv);
 
 				return -1;
 			}



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