From ba96adb65f2fd1e63e135c3d04ddd1aeff784704 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 29 Dec 2009 23:46:50 +0200 Subject: [PATCH] dbus: Verify dbus_message_new_method_return() return value before use --- wpa_supplicant/dbus/dbus_new_helpers.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/dbus/dbus_new_helpers.c b/wpa_supplicant/dbus/dbus_new_helpers.c index 56201712c..b2bad658b 100644 --- a/wpa_supplicant/dbus/dbus_new_helpers.c +++ b/wpa_supplicant/dbus/dbus_new_helpers.c @@ -589,7 +589,7 @@ static DBusMessage * introspect(DBusMessage *message, struct wpa_dbus_object_desc *obj_dsc) { - DBusMessage *reply = NULL; + DBusMessage *reply; struct interfaces *ifaces, *tmp; struct wpa_dbus_signal_desc *signal_dsc; struct wpa_dbus_method_desc *method_dsc; @@ -603,9 +603,6 @@ static DBusMessage * introspect(DBusMessage *message, xmlNodePtr method_node = NULL, signal_node = NULL; xmlNodePtr property_node = NULL, arg_node = NULL; - /* Create and initialize the return message */ - reply = dbus_message_new_method_return(message); - /* root node and dtd */ doc = xmlNewDoc(BAD_CAST "1.0"); root_node = xmlNewNode(NULL, BAD_CAST "node"); @@ -809,6 +806,12 @@ static DBusMessage * introspect(DBusMessage *message, os_free(tmp); } + reply = dbus_message_new_method_return(message); + if (reply == NULL) { + xmlFree(intro_str); + return NULL; + } + dbus_message_append_args(reply, DBUS_TYPE_STRING, &intro_str, DBUS_TYPE_INVALID);