From f1c75fc465d8451c3a343eddee7f45d5f3947d7a Mon Sep 17 00:00:00 2001 From: Jim Nelson Date: Wed, 30 Jul 2014 19:02:11 -0700 Subject: [PATCH] Patch major memory leak due to GMime bindings Discovered a few binding problems while working on another issue, in particular gmime_parser_construct_message()'s return object not being freed, which can hold an entire message (attachments and all) in memory. --- bindings/vapi/gmime-2.6.vapi | 18 +++++++++++------- bindings/vapi/gmime-2.6/gmime-2.6.files | 2 +- bindings/vapi/gmime-2.6/gmime-2.6.metadata | 9 ++++++++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/bindings/vapi/gmime-2.6.vapi b/bindings/vapi/gmime-2.6.vapi index 8d8c1045..59c6909a 100644 --- a/bindings/vapi/gmime-2.6.vapi +++ b/bindings/vapi/gmime-2.6.vapi @@ -173,7 +173,7 @@ namespace GMime { [CCode (cname = "g_mime_content_type_set_params")] public void set_params (GMime.Param @params); [CCode (cname = "g_mime_content_type_to_string")] - public unowned string to_string (); + public string to_string (); } [CCode (cheader_filename = "gmime/gmime.h")] public class CryptoContext : GLib.Object { @@ -546,7 +546,7 @@ namespace GMime { [CCode (cname = "g_mime_message_get_date")] public void get_date (out ulong date, out int tz_offset); [CCode (cname = "g_mime_message_get_date_as_string")] - public unowned string get_date_as_string (); + public string get_date_as_string (); [CCode (cname = "g_mime_message_get_message_id")] public unowned string get_message_id (); [CCode (cname = "g_mime_message_get_mime_part")] @@ -639,9 +639,9 @@ namespace GMime { [CCode (cname = "g_mime_multipart_remove")] public virtual bool remove (GMime.Object part); [CCode (cname = "g_mime_multipart_remove_at")] - public virtual unowned GMime.Object remove_at (int index); + public virtual GMime.Object remove_at (int index); [CCode (cname = "g_mime_multipart_replace")] - public unowned GMime.Object replace (int index, GMime.Object replacement); + public GMime.Object replace (int index, GMime.Object replacement); [CCode (cname = "g_mime_multipart_set_boundary")] public virtual void set_boundary (string boundary); [CCode (cname = "g_mime_multipart_set_postface")] @@ -698,7 +698,7 @@ namespace GMime { [CCode (cname = "g_mime_object_get_header_list")] public unowned GMime.HeaderList get_header_list (); [CCode (cname = "g_mime_object_get_headers")] - public virtual unowned string get_headers (); + public virtual string get_headers (); [CCode (cname = "g_mime_object_prepend_header")] public virtual void prepend_header (string header, string value); [CCode (cname = "g_mime_object_register_type")] @@ -758,9 +758,9 @@ namespace GMime { [CCode (cname = "g_mime_parser_new", has_construct_function = false)] public Parser (); [CCode (cname = "g_mime_parser_construct_message")] - public unowned GMime.Message? construct_message (); + public GMime.Message? construct_message (); [CCode (cname = "g_mime_parser_construct_part")] - public unowned GMime.Object construct_part (); + public GMime.Object? construct_part (); [CCode (cname = "g_mime_parser_eos")] public bool eos (); [CCode (cname = "g_mime_parser_get_from")] @@ -1016,6 +1016,8 @@ namespace GMime { public bool owner; [CCode (cname = "g_mime_stream_file_new", has_construct_function = false, type = "GMimeStream*")] public StreamFile (GLib.FileStream fp); + [CCode (cname = "g_mime_stream_file_new_for_path", has_construct_function = false, type = "GMimeStream*")] + public StreamFile.for_path (string path, string mode); [CCode (cname = "g_mime_stream_file_get_owner")] public bool get_owner (); [CCode (cname = "g_mime_stream_file_set_owner")] @@ -1040,6 +1042,8 @@ namespace GMime { public bool owner; [CCode (cname = "g_mime_stream_fs_new", has_construct_function = false, type = "GMimeStream*")] public StreamFs (int fd); + [CCode (cname = "g_mime_stream_fs_new_for_path", has_construct_function = false, type = "GMimeStream*")] + public StreamFs.for_path (string path, int flags, int mode); [CCode (cname = "g_mime_stream_fs_get_owner")] public bool get_owner (); [CCode (cname = "g_mime_stream_fs_set_owner")] diff --git a/bindings/vapi/gmime-2.6/gmime-2.6.files b/bindings/vapi/gmime-2.6/gmime-2.6.files index 5d11dcee..425d3d34 100644 --- a/bindings/vapi/gmime-2.6/gmime-2.6.files +++ b/bindings/vapi/gmime-2.6/gmime-2.6.files @@ -1,2 +1,2 @@ include/gmime-2.6/ -lib/libgmime-2.6.so +lib/x86_64-linux-gnu/libgmime-2.6.so diff --git a/bindings/vapi/gmime-2.6/gmime-2.6.metadata b/bindings/vapi/gmime-2.6/gmime-2.6.metadata index 903a535c..f080d906 100644 --- a/bindings/vapi/gmime-2.6/gmime-2.6.metadata +++ b/bindings/vapi/gmime-2.6/gmime-2.6.metadata @@ -3,16 +3,22 @@ GMime lower_case_cprefix="gmime_" cheader_filename="gmime/gmime.h" GMimeObject abstract="1" GMimeStream abstract="1" +g_mime_content_type_to_string transfer_ownership="1" g_mime_header_list_get_iter.iter is_out="1" g_mime_message_get_date.date is_out="1" g_mime_message_get_date.tz_offset is_out="1" +g_mime_message_get_date_as_string transfer_ownership="1" g_mime_message_get_mime_part is_nullable="1" +g_mime_multipart_remove_at is_nullable="1" transfer_ownership="1" +g_mime_multipart_replace is_nullable="1" transfer_ownership="1" g_mime_object_get_content_disposition nullable="1" g_mime_object_get_content_type nullable="1" g_mime_object_get_content_type_parameter nullable="1" +g_mime_object_get_headers transfer_ownership="1" g_mime_object_to_string transfer_ownership="1" g_mime_param_next name="get_next" -g_mime_parser_construct_message nullable="1" +g_mime_parser_construct_message nullable="1" transfer_ownership="1" +g_mime_parser_construct_part nullable="1" transfer_ownership="1" g_mime_part_get_content_description nullable="1" g_mime_part_get_content_location nullable="1" g_mime_part_get_content_id nullable="1" @@ -50,6 +56,7 @@ GMimeFilter.outpre is_protected="1" GMimeFilter.outptr type_name="char*" is_protected="1" GMimeFilter.outreal type_name="char*" is_protected="1" GMimeFilter.outsize hidden="1" is_protected="1" +GMimeFilterBest.charset hidden="1" g_mime_filter_backup.data is_array="1" array_length_pos="1.1" array_length_type="size_t" type_name="char[]" g_mime_filter_backup.length hidden="1"