diff options
author | Not Zed <NotZed@Ximian.com> | 2001-01-23 06:35:41 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-01-23 06:35:41 +0800 |
commit | 92403a5b3ab4410e235415b1b36f37a1ff281e0e (patch) | |
tree | 74d42f224f65daca7bfeba2a58dd8df20c358142 /mail/mail-crypto.c | |
parent | 48d74a5f32050efd7cbd162fbd7076731cf56555 (diff) | |
download | gsoc2013-evolution-92403a5b3ab4410e235415b1b36f37a1ff281e0e.tar.gz gsoc2013-evolution-92403a5b3ab4410e235415b1b36f37a1ff281e0e.tar.zst gsoc2013-evolution-92403a5b3ab4410e235415b1b36f37a1ff281e0e.zip |
Fix a double-free problem.
2001-01-23 Not Zed <NotZed@Ximian.com>
* mail-crypto.c (pgp_mime_part_verify): Fix a double-free problem.
svn path=/trunk/; revision=7722
Diffstat (limited to 'mail/mail-crypto.c')
-rw-r--r-- | mail/mail-crypto.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/mail/mail-crypto.c b/mail/mail-crypto.c index ae4ce6c803..b343e8cda8 100644 --- a/mail/mail-crypto.c +++ b/mail/mail-crypto.c @@ -257,12 +257,11 @@ pgp_mime_part_verify (CamelMimePart *mime_part, CamelException *ex) CamelDataWrapper *wrapper; CamelMultipart *multipart; CamelMimePart *part, *sigpart; - GByteArray *content, *sig; CamelStreamFilter *filtered_stream; CamelMimeFilter *crlf_filter; - CamelStream *stream; gboolean valid = FALSE; - + CamelStreamMem *sigstream, *cstream; + g_return_val_if_fail (mime_part != NULL, FALSE); g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), FALSE); @@ -274,31 +273,25 @@ pgp_mime_part_verify (CamelMimePart *mime_part, CamelException *ex) /* get the plain part */ part = camel_multipart_get_part (multipart, 0); - content = g_byte_array_new (); - stream = camel_stream_mem_new (); - camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (stream), content); - crlf_filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, - CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); - filtered_stream = camel_stream_filter_new_with_stream (stream); + cstream = (CamelStreamMem *)camel_stream_mem_new (); + crlf_filter = camel_mime_filter_crlf_new (CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); + filtered_stream = camel_stream_filter_new_with_stream ((CamelStream *)cstream); camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (crlf_filter)); camel_object_unref (CAMEL_OBJECT (crlf_filter)); camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (part), CAMEL_STREAM (filtered_stream)); camel_object_unref (CAMEL_OBJECT (filtered_stream)); - camel_object_unref (CAMEL_OBJECT (stream)); /* get the signed part */ sigpart = camel_multipart_get_part (multipart, 1); - sig = g_byte_array_new (); - stream = camel_stream_mem_new_with_byte_array (sig); - camel_data_wrapper_write_to_stream (camel_medium_get_content_object (CAMEL_MEDIUM (sigpart)), stream); - camel_object_unref (CAMEL_OBJECT (stream)); + sigstream = (CamelStreamMem *)camel_stream_mem_new (); + camel_data_wrapper_write_to_stream (camel_medium_get_content_object (CAMEL_MEDIUM (sigpart)), (CamelStream *)sigstream); /* verify */ - valid = openpgp_verify (content->data, content->len, - sig->data, sig->len, ex); - - g_byte_array_free (content, TRUE); - g_byte_array_free (sig, TRUE); + valid = openpgp_verify (cstream->buffer->data, cstream->buffer->len, + sigstream->buffer->data, sigstream->buffer->len, ex); + + camel_object_unref (CAMEL_OBJECT (sigstream)); + camel_object_unref (CAMEL_OBJECT (cstream)); return valid; } |