mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 20:35:49 +01:00
7d61da0c07
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