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 657481 - Abstract properties' get() and set() functions aren't NULL-safe
Abstract properties' get() and set() functions aren't NULL-safe
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator: GObject
0.13.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-08-27 00:57 UTC by Travis Reitter
Modified: 2011-08-27 08:36 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Travis Reitter 2011-08-27 00:57:31 UTC
This code:

public interface Folks.AliasDetails : Object
{
  public abstract string alias { get; set; }
}

Ends up generating this C:

const gchar* folks_alias_details_get_alias (FolksAliasDetails* self) {
  return FOLKS_ALIAS_DETAILS_GET_INTERFACE (self)->get_alias (self);
}

void folks_alias_details_set_alias (FolksAliasDetails* self, const gchar* value) {
  FOLKS_ALIAS_DETAILS_GET_INTERFACE (self)->set_alias (self, value);
}

======

So, if client code blindly passes in NULL for self, it'll segfault. I think the generated code should include a g_return(_val)_if_fail() check like the class implementations to avoid this.
Comment 1 Luca Bruno 2011-08-27 08:36:09 UTC
commit b10c156018783f7bd1c9f28a71297da7988a26b5
Author: Luca Bruno <lucabru@src.gnome.org>
Date:   Sat Aug 27 09:49:29 2011 +0200

    codegen: Add type check in property vfunc
    
    Fixes bug 657481.

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.