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 514864 - nullable struct parameter dereferenced
nullable struct parameter dereferenced
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.1.x
Other All
: Normal normal
: ---
Assigned To: Jürg Billeter
Vala maintainers
: 520795 522353 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-02-06 21:41 UTC by Vlad Grecescu
Modified: 2008-03-15 02:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed fix (3.25 KB, patch)
2008-03-15 02:16 UTC, Alberto Ruiz
committed Details | Review

Description Vlad Grecescu 2008-02-06 21:41:37 UTC
Please describe the problem:
For a method who's signature is
public bool iter_nth_child (out Gtk.TreeIter iter, weak Gtk.TreeIter? parent, int n)

vala generates for 
   if ( ref parent != null)
the following C code:
   parent = *_parent_p; //segfaults here
   if (&parent != NULL)


Steps to reproduce:



Actual results:
The code segfaults as parent can be null

Expected results:
the _parent_p should not be dereferenced if I only use ref parent

Does this happen every time?
yes

Other information:
Vala 0.1.6
Comment 1 Jürg Billeter 2008-02-07 16:09:56 UTC
    if (ref parent != null)

This is invalid code, it should be

    if (parent != null)

However, the crash will still happen, which is obviously a bug.
Comment 2 Jürg Billeter 2008-03-08 19:39:28 UTC
*** Bug 520795 has been marked as a duplicate of this bug. ***
Comment 3 Jürg Billeter 2008-03-14 18:53:37 UTC
*** Bug 522353 has been marked as a duplicate of this bug. ***
Comment 4 Alberto Ruiz 2008-03-15 02:16:29 UTC
Created attachment 107327 [details] [review]
Proposed fix
Comment 5 Jürg Billeter 2008-03-15 02:49:09 UTC
2008-03-15  Jürg Billeter  <j@bitron.ch>

	* gobject/valaccodegenerator.vala,
	  gobject/valaccodegeneratormemberaccess.vala,
	  gobject/valaccodegeneratormethod.vala: fix runtime crash when
	  using nullable struct parameters,
	  patch by Alberto Ruiz, fixes bug 514864

Fixed in r1127.