← Back to team overview

ayatana-commits team mailing list archive

[Branch ~dbusmenu-team/dbusmenu/trunk] Rev 132: Protecting from getting passed NULL GValues

 

Merge authors:
  Ted Gould (ted)
Related merge proposals:
  https://code.launchpad.net/~ted/dbusmenu/null-values-make-vala-smile/+merge/29875
  proposed by: Ted Gould (ted)
  review: Approve - Gord Allott (gordallott)
------------------------------------------------------------
revno: 132 [merge]
committer: Ted Gould <ted@xxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-07-14 09:25:12 -0500
message:
  Protecting from getting passed NULL GValues
modified:
  libdbusmenu-glib/client.c


--
lp:dbusmenu
https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk

Your team ayatana-commits is subscribed to branch lp:dbusmenu.
To unsubscribe from this branch go to https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk/+edit-subscription
=== modified file 'libdbusmenu-glib/client.c'
--- libdbusmenu-glib/client.c	2010-07-07 19:45:26 +0000
+++ libdbusmenu-glib/client.c	2010-07-14 14:02:15 +0000
@@ -716,6 +716,17 @@
 void
 dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name, const GValue * value, guint timestamp)
 {
+	g_return_if_fail(DBUSMENU_IS_CLIENT(client));
+	g_return_if_fail(id >= 0);
+	g_return_if_fail(name != NULL);
+
+	if (value == NULL) {
+		GValue internalval = {0};
+		g_value_init(&internalval, G_TYPE_INT);
+		g_value_set_int(&internalval, 0);
+		value = &internalval;
+	}
+
 	DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
 	org_ayatana_dbusmenu_event_async (priv->menuproxy, id, name, value, timestamp, menuitem_call_cb, GINT_TO_POINTER(id));
 	return;