After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 768413 - function: Release out args before freeing caller allocated structs
function: Release out args before freeing caller allocated structs
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks: 768381
 
 
Reported: 2016-07-04 20:45 UTC by Florian Müllner
Modified: 2016-07-05 07:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
function: Release out args before freeing caller allocated structs (3.14 KB, patch)
2016-07-04 20:45 UTC, Florian Müllner
committed Details | Review

Description Florian Müllner 2016-07-04 20:45:47 UTC
See patch.

This fixes a crash with the following test program for me:

    const Gtk = imports.gi.Gtk;

    Gtk.init(null, null);

    let w = new Gtk.Label();
    let context = w.get_style_context();
    context.add_class('dim-label')
    log(context.get_property('opacity', context.get_state()));
Comment 1 Florian Müllner 2016-07-04 20:45:51 UTC
Created attachment 330869 [details] [review]
function: Release out args before freeing caller allocated structs

If an out arg is caller allocated, we need to free the memory we
allocated for it (for instance a GValue), but also release any
memory allocated for struct members (for instance a string held by
a GValue). We currently do these operations in this order, so the
pointer used for releasing the argument points to memory invalidated
by the earlier free call, which is likely to crash. To fix, reverse
the order of the operations to first release the argument and then
free the caller-allocated struct.
Comment 2 Colin Walters 2016-07-05 01:05:02 UTC
Review of attachment 330869 [details] [review]:

Makes sense to me.
Comment 3 Florian Müllner 2016-07-05 07:54:28 UTC
Attachment 330869 [details] pushed as eb13ed4 - function: Release out args before freeing caller allocated structs