[gedit] Check that convert_text() succeeded



commit baa1fe0a050733a7f5a93f43ce240e08e7814b6b
Author: Daniel Trebbien <dtrebbien gmail com>
Date:   Sat Feb 11 14:02:56 2012 -0800

    Check that convert_text() succeeded
    
    validate_and_insert() does not allow its `buffer` parameter to be NULL.
    In gedit_document_output_stream_flush(), if convert_text() fails, then
    `outbuf` will be NULL and validate_and_insert() will be called with a
    NULL `buffer`.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=669909

 gedit/gedit-document-output-stream.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gedit/gedit-document-output-stream.c b/gedit/gedit-document-output-stream.c
index 4328da2..ebc8f80 100644
--- a/gedit/gedit-document-output-stream.c
+++ b/gedit/gedit-document-output-stream.c
@@ -1006,9 +1006,15 @@ gedit_document_output_stream_flush (GOutputStream  *stream,
 		gchar *outbuf;
 		gsize outbuf_len;
 
-		convert_text (ostream, NULL, 0, &outbuf, &outbuf_len, error);
-		validate_and_insert (ostream, outbuf, outbuf_len);
-		g_free (outbuf);
+		if (convert_text (ostream, NULL, 0, &outbuf, &outbuf_len, error))
+		{
+			validate_and_insert (ostream, outbuf, outbuf_len);
+			g_free (outbuf);
+		}
+		else
+		{
+			return FALSE;
+		}
 	}
 
 	if (ostream->priv->buflen > 0 && *ostream->priv->buffer != '\r')



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