gdbus-codegen: Fix crasher in goa-using apps
authorBastien Nocera <hadess@hadess.net>
Mon, 16 Dec 2013 16:21:41 +0000 (17:21 +0100)
committerBastien Nocera <hadess@hadess.net>
Wed, 18 Dec 2013 09:53:01 +0000 (10:53 +0100)
When replacing a version of goa-daemon (from gnome-online-accounts)
by a newer version with some added interfaces, evolution-data-server
and the gvfs-goa volume monitor might crash as there's no interface
definition for this new interface.

Work-around this by returning earlier from the _notify() implementation,
rather than accessing invalid memory.

https://bugzilla.gnome.org/show_bug.cgi?id=720539

gio/gdbus-2.0/codegen/codegen.py

index e72cb31..c711d44 100644 (file)
@@ -2768,7 +2768,12 @@ class CodeGenerator:
         self.c.write('static void\n'
                      '%sobject_notify (GDBusObject *object, GDBusInterface *interface)\n'
                      '{\n'
-                     '  g_object_notify (G_OBJECT (object), ((_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface))->hyphen_name);\n'
+                     '  _ExtendedGDBusInterfaceInfo *info = (_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface);\n'
+                     '  /* info can be NULL if the other end is using a D-Bus interface we don\'t know\n'
+                     '   * anything about, for example old generated code in this process talking to\n'
+                     '   * newer generated code in the other process. */\n'
+                     '  if (info != NULL)\n'
+                     '    g_object_notify (G_OBJECT (object), info->hyphen_name);\n'
                      '}\n'
                      '\n'
                      %(self.ns_lower))