[gmime] Don't unref the encrypted part on error



commit 0e77212252cb7028ecfd28901df291f01382410d
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Sun Jun 20 10:52:43 2010 -0400

    Don't unref the encrypted part on error
    
    2010-06-20  Jeffrey Stedfast  <fejj novell com>
    
    	* gmime/gmime-multipart-encrypted.c
    	* (g_mime_multipart_encrypted_decrypt):
    	Don't unref the encrypted content mime part object when the
    	content-type doesn't match application/octet-stream,
    	g_mime_multipart_get_part() does not ref parts it returns. We
    also
    	need to set an error when this happens.

 ChangeLog                         |    8 ++++++++
 gmime/gmime-multipart-encrypted.c |    4 +++-
 2 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1dc6232..c2e2300 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-06-20  Jeffrey Stedfast  <fejj novell com>
+
+	* gmime/gmime-multipart-encrypted.c (g_mime_multipart_encrypted_decrypt):
+	Don't unref the encrypted content mime part object when the
+	content-type doesn't match application/octet-stream,
+	g_mime_multipart_get_part() does not ref parts it returns. We also
+	need to set an error when this happens.
+
 2010-05-18  Jeffrey Stedfast  <fejj novell com>
 
 	* README: Bumped version
diff --git a/gmime/gmime-multipart-encrypted.c b/gmime/gmime-multipart-encrypted.c
index cb0e7de..8adeba0 100644
--- a/gmime/gmime-multipart-encrypted.c
+++ b/gmime/gmime-multipart-encrypted.c
@@ -318,7 +318,9 @@ g_mime_multipart_encrypted_decrypt (GMimeMultipartEncrypted *mpe, GMimeCipherCon
 	encrypted = g_mime_multipart_get_part (GMIME_MULTIPART (mpe), GMIME_MULTIPART_ENCRYPTED_CONTENT);
 	mime_type = g_mime_object_get_content_type (encrypted);
 	if (!g_mime_content_type_is_type (mime_type, "application", "octet-stream")) {
-		g_object_unref (encrypted);
+		g_set_error (err, GMIME_ERROR, GMIME_ERROR_PROTOCOL_ERROR,
+			     "Failed to decrypt MIME part: unexpected content type");
+		
 		return NULL;
 	}
 	



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