From 4cdf1eafd1d16a70dfb5199ecab0ac2ce46982c8 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 28 Aug 2014 17:56:48 -0500 Subject: Fix memory leak on calling TQT_DBusConnection::sendWithReply Notably tdepowersave no longer leaks memory after this patch --- tqdbusconnection.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tqdbusconnection.cpp b/tqdbusconnection.cpp index a62735e..0360456 100644 --- a/tqdbusconnection.cpp +++ b/tqdbusconnection.cpp @@ -280,8 +280,8 @@ TQT_DBusMessage TQT_DBusConnection::sendWithReply(const TQT_DBusMessage &message DBusMessage *msg = message.toDBusMessage(); if (!msg) return TQT_DBusMessage::fromDBusMessage(0); - DBusMessage *reply = dbus_connection_send_with_reply_and_block(d->connection, msg, - -1, &d->error); + + DBusMessage *reply = dbus_connection_send_with_reply_and_block(d->connection, msg, -1, &d->error); if (d->handleError() && error) *error = d->lastError; @@ -289,6 +289,9 @@ TQT_DBusMessage TQT_DBusConnection::sendWithReply(const TQT_DBusMessage &message dbus_message_unref(msg); TQT_DBusMessage ret = TQT_DBusMessage::fromDBusMessage(reply); + if (reply) { + dbus_message_unref(reply); + } bool dbus_error_set = dbus_error_is_set(&d->error); ret.d->error.setDBUSError(dbus_error_set); -- cgit v1.2.1