Merge branch 'libytnef-fix-invalid-alloc-size-new-abi' into 'mainline'

libytnef: properly initialize struct

See merge request GNOME/geary!509
This commit is contained in:
Michael Gratton 2020-05-18 01:52:03 +00:00
commit 7580ce49d8
2 changed files with 5 additions and 3 deletions

View file

@ -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);

View file

@ -1022,8 +1022,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)));
}