GNOME Bugzilla – Bug 795265
[PATCH] vapi: json-glib make gvariant_deserialize return nullable
Last modified: 2018-04-15 17:47:21 UTC
Created attachment 370940 [details] [review] [PATCH] vapi: json-glib make gvariant_deserialize return nullable I've submitted a merge request here to fix the GIR generation: https://gitlab.gnome.org/GNOME/json-glib/merge_requests/10 The changes to the vapi were generated by vapigen after running it on the GIR as updated in the merge request above. The lack of the nullable flag was causing me some memory leak issues when those methods returned null.
@david Could you provide an example which shows the mentioned memory leak?
Sorry, after doing some more testing, I think the memory leak issues are unrelated to this. It seems like some unhanded exceptions/assertions that were caused by calling g_variant_ref_sink and using one of the NULL pointers returned by the patched methods later on in my code was what was causing issues. I don't think there's anything more to be done in Vala for this, as adding the nullable flag causes g_variant_ref_sink to be wrapped in a null check.
I see. I was wondering if we can catch that somehow by not unconditionally calling ref_sink on possible null. Meaning, if the origin of the floating instance comes from a function which throws an error then treat it as nullable.
Review of attachment 370940 [details] [review]: This can't be applied this way. Either wait for upstream annotations are fixed and source gir is updated, or the corresponding metadata is required.
Created attachment 370953 [details] [review] Also update metadata
(In reply to Rico Tzschichholz from comment #3) > Meaning, if the origin of the floating instance comes from a function which > throws an error then treat it as nullable. That may be worthwhile, I suppose it's quite common for the returned pointer to be null if there was an error thrown in the method.
Created attachment 370954 [details] [review] vala: Treat floating method-return-type as nullable if error may be thrown
Comment on attachment 370954 [details] [review] vala: Treat floating method-return-type as nullable if error may be thrown Attachment 370954 [details] pushed as d6be549 - vala: Treat floating method-return-type as nullable if error may be thrown