aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-03-24 10:58:04 -0500
committerTed Gould <ted@gould.cx>2011-03-24 10:58:04 -0500
commitcccd3fc83553dd525d620f069c7cacbe89e3f322 (patch)
tree9fbf4cb2edb9855a3551ea8ecc3c9a3293ec14a5 /libdbusmenu-glib
parente7acae9db34e6abea6b7aa1fe532ad18e13577c7 (diff)
downloadlibdbusmenu-cccd3fc83553dd525d620f069c7cacbe89e3f322.tar.gz
libdbusmenu-cccd3fc83553dd525d620f069c7cacbe89e3f322.tar.bz2
libdbusmenu-cccd3fc83553dd525d620f069c7cacbe89e3f322.zip
Put in some more protections on the types for property variants and generate some errors
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/client.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index 24d5c5d..049cc91 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -1333,8 +1333,16 @@ menuitem_get_properties_cb (GVariant * properties, GError * error, gpointer data
if (error != NULL) {
g_warning("Error getting properties on a menuitem: %s", error->message);
- g_object_unref(data);
- return;
+ goto out;
+ }
+
+ if (properties == NULL) {
+ goto out;
+ }
+
+ if (!g_variant_is_of_type(properties, G_VARIANT_TYPE("a{sv}"))) {
+ g_warning("Properties are of type '%s' instead of type '%s'", g_variant_get_type_string(properties), "a{sv}");
+ goto out;
}
GVariantIter iter;
@@ -1347,6 +1355,7 @@ menuitem_get_properties_cb (GVariant * properties, GError * error, gpointer data
dbusmenu_menuitem_property_set_variant(item, key, value);
}
+out:
g_object_unref(data);
return;
@@ -1365,12 +1374,16 @@ menuitem_get_properties_replace_cb (GVariant * properties, GError * error, gpoin
g_warning("Unable to replace properties on %d: %s", dbusmenu_menuitem_get_id(DBUSMENU_MENUITEM(data)), error->message);
have_error = TRUE;
}
+
+ if (properties == NULL) {
+ have_error = TRUE;
+ }
/* Get the list of the current properties */
GList * current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data));
GList * tmp = NULL;
- if (properties != NULL) {
+ if (!have_error && g_variant_is_of_type(properties, G_VARIANT_TYPE("a{sv}"))) {
GVariantIter iter;
g_variant_iter_init(&iter, properties);
gchar * name; GVariant * value;
@@ -1414,8 +1427,12 @@ menuitem_get_properties_new_cb (GVariant * properties, GError * error, gpointer
if (error != NULL) {
g_warning("Error getting properties on a new menuitem: %s", error->message);
- g_object_unref(propdata->item);
- return;
+ goto out;
+ }
+
+ if (properties == NULL) {
+ g_warning("Not realizing new item as properties for it were unavailable");
+ goto out;
}
DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(propdata->client);
@@ -1449,6 +1466,7 @@ menuitem_get_properties_new_cb (GVariant * properties, GError * error, gpointer
g_signal_emit(G_OBJECT(propdata->client), signals[NEW_MENUITEM], 0, propdata->item, TRUE);
}
+out:
g_object_unref(propdata->item);
g_free(propdata);