Patch: fix in tny_camel_mime_part_decode_to_stream



Hi

this patch ensures that during a decode_to_stream operation we'll always
have a valid reference to the mime part. Otherwise it could happen that
we could be removing the mime part while decoding it (for example if we
want to purge that mime part at the same time).

Br
Index: libtinymail-camel/tny-camel-mime-part.c
===================================================================
--- libtinymail-camel/tny-camel-mime-part.c	(revision 3808)
+++ libtinymail-camel/tny-camel-mime-part.c	(working copy)
@@ -781,6 +781,7 @@
 	g_mutex_unlock (priv->part_lock);
 
 	wrapper = camel_medium_get_content_object (medium);
+	camel_object_ref (wrapper);
 
 	if (G_UNLIKELY (!wrapper)) {
 		g_warning (_("Mime part does not yet have a source stream, use "
@@ -788,15 +789,16 @@
 		camel_object_unref (CAMEL_OBJECT (cstream));
 		return -1;
 	}
-	
+
 	if (camel_content_type_is (wrapper->mime_type, "text", "*"))
 		bytes = (gssize) camel_stream_format_text (wrapper, cstream);
 	else
 		bytes = (gssize) camel_data_wrapper_decode_to_stream (wrapper, cstream);
 
+	camel_object_unref (wrapper);
 	camel_object_unref (cstream);
 	camel_object_unref (medium);
-	
+
 	if (bytes < 0) {
 		g_set_error (err, TNY_IO_ERROR, 
 				TNY_IO_ERROR_WRITE,


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