[PATCH] raop: Fix a memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



a.path_or_host wasn't freed after calling pa_parse_address().
---

I needed pa_parse_address() in my module-tunnel-manager work, and I
found the interface to be prone to memory leaks, so I decided to
check all call sites of the function. I found one leak. I've added it
to my todo list to make the function interface safer, but I don't
expect to get around to that task any time soon, so if anyone else
wants to fix it, be my guest.


 src/modules/raop/raop_client.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/modules/raop/raop_client.c b/src/modules/raop/raop_client.c
index 5bb0bb4..7a6d009 100644
--- a/src/modules/raop/raop_client.c
+++ b/src/modules/raop/raop_client.c
@@ -372,14 +372,19 @@ pa_raop_client* pa_raop_client_new(pa_core *core, const char* host) {
     pa_assert(core);
     pa_assert(host);
 
-    if (pa_parse_address(host, &a) < 0 || a.type == PA_PARSED_ADDRESS_UNIX)
+    if (pa_parse_address(host, &a) < 0)
         return NULL;
 
+    if (a.type == PA_PARSED_ADDRESS_UNIX) {
+        pa_xfree(a.path_or_host);
+        return NULL;
+    }
+
     c = pa_xnew0(pa_raop_client, 1);
     c->core = core;
     c->fd = -1;
 
-    c->host = pa_xstrdup(a.path_or_host);
+    c->host = a.path_or_host;
     if (a.port)
         c->port = a.port;
     else
-- 
1.9.3



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux