[pulseaudio-discuss] [PATCH] Fix memory leaks

Jungsup Lee jungsup4.lee at samsung.com
Wed Mar 14 06:28:54 UTC 2018


The returned string of the dbus_message_iter_get_signature() must be freed with dbus_free().
---
 src/modules/module-stream-restore.c | 8 +++++++-
 src/pulsecore/dbus-util.c           | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 7ee53340..162d5fef 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -346,14 +346,20 @@ static void dbus_entry_free(struct dbus_entry *de) {
 static int get_volume_arg(DBusConnection *conn, DBusMessage *msg, DBusMessageIter *iter, pa_channel_map *map, pa_cvolume *vol) {
     DBusMessageIter array_iter;
     DBusMessageIter struct_iter;
+    char *signature;
 
     pa_assert(conn);
     pa_assert(msg);
     pa_assert(iter);
-    pa_assert(pa_streq(dbus_message_iter_get_signature(iter), "a(uu)"));
     pa_assert(map);
     pa_assert(vol);
 
+    signature = dbus_message_iter_get_signature(iter);
+    pa_assert(pa_streq(signature, "a(uu)"));
+
+    if (signature)
+        dbus_free(signature);
+
     pa_channel_map_init(map);
     pa_cvolume_init(vol);
 
diff --git a/src/pulsecore/dbus-util.c b/src/pulsecore/dbus-util.c
index 80e2866e..8053dacf 100644
--- a/src/pulsecore/dbus-util.c
+++ b/src/pulsecore/dbus-util.c
@@ -735,6 +735,7 @@ void pa_dbus_append_proplist_variant_dict_entry(DBusMessageIter *dict_iter, cons
 pa_proplist *pa_dbus_get_proplist_arg(DBusConnection *c, DBusMessage *msg, DBusMessageIter *iter) {
     DBusMessageIter dict_iter;
     DBusMessageIter dict_entry_iter;
+    char *signature;
     pa_proplist *proplist = NULL;
     const char *key = NULL;
     const uint8_t *value = NULL;
@@ -743,7 +744,12 @@ pa_proplist *pa_dbus_get_proplist_arg(DBusConnection *c, DBusMessage *msg, DBusM
     pa_assert(c);
     pa_assert(msg);
     pa_assert(iter);
-    pa_assert(pa_streq(dbus_message_iter_get_signature(iter), "a{say}"));
+
+    signature = dbus_message_iter_get_signature(iter);
+    pa_assert(pa_streq(signature, "a{say}"));
+
+    if (signature)
+        dbus_free(signature);
 
     proplist = pa_proplist_new();
 
-- 
2.13.GIT



More information about the pulseaudio-discuss mailing list