From b167550cab283869d5c5241425c2644df6c8b885 Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Sun, 3 May 2020 08:26:10 +1200 Subject: [PATCH] libytnef: properly initialize struct Call TNEFInitialize on the TNEFStruct before use to make sure all fields are initialized to their default values. Since libytnef 2.0.0 zero-initialization is not sufficient. --- bindings/vapi/libytnef.vapi | 4 +++- src/engine/rfc822/rfc822-message.vala | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bindings/vapi/libytnef.vapi b/bindings/vapi/libytnef.vapi index 6ca59405..50e27d19 100644 --- a/bindings/vapi/libytnef.vapi +++ b/bindings/vapi/libytnef.vapi @@ -44,11 +44,13 @@ namespace Ytnef { [CCode (cname = "TNEFStruct", destroy_function="TNEFFree", has_type_id = false)] public struct TNEFStruct { + [CCode (cname = "TNEFInitialize")] + public TNEFStruct(); Attachment starting_attach; } [CCode (cname = "TNEFParseMemory", has_type_id = false)] - public static int ParseMemory(uint8[] data, out TNEFStruct tnef); + public static int ParseMemory(uint8[] data, ref TNEFStruct tnef); [CCode (cname = "MAPIFindProperty")] public static unowned VariableLength* MAPIFindProperty(MAPIProps MAPI, uint tag); diff --git a/src/engine/rfc822/rfc822-message.vala b/src/engine/rfc822/rfc822-message.vala index 4ef341c8..11490e55 100644 --- a/src/engine/rfc822/rfc822-message.vala +++ b/src/engine/rfc822/rfc822-message.vala @@ -1024,8 +1024,8 @@ public class Geary.RFC822.Message : BaseObject, EmailHeaderSet { GMime.StreamMem stream = new GMime.StreamMem(); ((GMime.Part) root).get_content().write_to_stream(stream); ByteArray tnef_data = stream.get_byte_array(); - Ytnef.TNEFStruct tn; - if (Ytnef.ParseMemory(tnef_data.data, out tn) == 0) { + Ytnef.TNEFStruct tn = Ytnef.TNEFStruct(); + if (Ytnef.ParseMemory(tnef_data.data, ref tn) == 0) { for (unowned Ytnef.Attachment? a = tn.starting_attach.next; a != null; a = a.next) { attachments.add(new Part(tnef_attachment_to_gmime_part(a))); }