diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-02-12 17:51:23 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-02-12 17:51:23 -0600 |
commit | 9f74296c2bd1b147c0818104b389f8fb38a2d344 (patch) | |
tree | e20b6bf7b0f42baaf4a32defca572b5486ff6468 | |
parent | 4c0790da4fe55084f82b5df4b9d7fe25f1558b0a (diff) | |
download | ofono-9f74296c2bd1b147c0818104b389f8fb38a2d344.tar.bz2 |
Don't leak user_data in send_method_call_with_reply
-rw-r--r-- | plugins/hfp.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/plugins/hfp.c b/plugins/hfp.c index 0b5b53cc..96823622 100644 --- a/plugins/hfp.c +++ b/plugins/hfp.c @@ -221,19 +221,21 @@ static int send_method_call_with_reply(const char *dest, const char *path, DBusMessage *msg; DBusPendingCall *call; va_list args; + int err; msg = dbus_message_new_method_call(dest, path, interface, method); if (!msg) { ofono_error("Unable to allocate new D-Bus %s message", method); - return -ENOMEM; + err = -ENOMEM; + goto fail; } va_start(args, type); if (!dbus_message_append_args_valist(msg, type, args)) { - dbus_message_unref(msg); va_end(args); - return -EIO; + err = -EIO; + goto fail; } va_end(args); @@ -243,8 +245,8 @@ static int send_method_call_with_reply(const char *dest, const char *path, if (!dbus_connection_send_with_reply(connection, msg, &call, timeout)) { ofono_error("Sending %s failed", method); - dbus_message_unref(msg); - return -EIO; + err = -EIO; + goto fail; } dbus_pending_call_set_notify(call, cb, user_data, free_func); @@ -252,6 +254,15 @@ static int send_method_call_with_reply(const char *dest, const char *path, dbus_message_unref(msg); return 0; + +fail: + if (free_func && user_data) + free_func(user_data); + + if (msg) + dbus_message_unref(msg); + + return err; } typedef void (*PropertyHandler)(DBusMessageIter *iter, gpointer user_data); |