glib/gobject
Ryan Lortie 7d61da0c07 g_object_new: check for NULL from _constructor()
There is some code in the wild (like in gnome-session) that does this
from its custom _constructor() implementation:

{
  GObject *obj;

  obj = ((chain up));

  if (!object_is_viable (obj))
    {
      g_object_unref (obj);
      return NULL;
    }
  else
    return obj;
}

This has never been a valid use of GObject and this code has always
caused memory to be leaked[1] by growing the construction_objects list.
The ability to legitimately return NULL from a constructor was exactly
the reason that we created GInitable, in fact.

That doesn't change the fact that the g_object_new() rewrite will crash
in this case, so instead of doing that, let's emit a critical and avoid
the crash.  This will allow people to upgrade their GLib without also
upgrading their gnome-session.  Meanwhile, people can fix their broken
code.

[1] not in the strictest sense of the word, because it's still reachable
2013-04-26 11:34:27 -04:00
..
2009-03-31 19:39:16 -04:00
2013-01-01 13:54:54 -05:00
2011-12-13 23:01:51 -05:00
2012-03-08 14:51:22 +08:00
2012-10-16 09:39:24 -04:00
2013-03-15 09:07:30 +01:00
2013-02-22 00:54:50 +00:00
2012-10-16 09:39:24 -04:00