GNOME Bugzilla – Bug 710882
Implicitly created variants are leaked
Last modified: 2017-03-25 14:49:39 UTC
When passing a value into a function expecting an GVariant like this var action = new SimpleAction.stateful ("test", null, 5), vala leaks the implicitly created variant: static GVariant* _variant_new1 (gint value) { return g_variant_ref_sink (g_variant_new_int32 (value)); } /* ... */ _tmp0_ = _variant_new1 (5); _tmp1_ = g_simple_action_new_stateful ("test", NULL, _tmp0_); /* _tmp0_ is never freed */
Does g_simple_action_new_stateful takes ownership of the gvariant? The docs aren't very clear.
No, g_simple_action_new_stateful() simply takes another ref. To be more precise, it sinks the variant that you pass in with g_variant_ref_sink(). This is so that you can pass a floating variant without having to unref it later. Vala passes an already-sinked variant though.
commit c726aefc51e2bb0d23f37066d365cb3d8456f195 Author: Luca Bruno <lucabru@src.gnome.org> Date: Sat Oct 26 11:32:23 2013 +0200 Fix memory leak when assigning an owned gvariant to an unowned variable Fixes bug 710882. This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Wrong hash: b6f7cd6c2aaf5dee64f618a0e06b0d0c157ea352