[pulseaudio-discuss] [PATCH v2 04/10] raop: Fix memleak

Peter Meerwald-Stadler pmeerw at pmeerw.net
Mon Mar 6 07:43:16 UTC 2017


use local scope for trs variable simplifying cleanup
Coverity ID: #1398160

Signed-off-by: Peter Meerwald-Stadler <pmeerw at pmeerw.net>
---
 src/modules/raop/raop-client.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c
index e39663d..4c3083e 100644
--- a/src/modules/raop/raop-client.c
+++ b/src/modules/raop/raop-client.c
@@ -983,14 +983,13 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
             pa_socket_client *sc = NULL;
             uint32_t sport = DEFAULT_UDP_AUDIO_PORT;
             uint32_t cport =0, tport = 0;
-            char *ajs, *trs, *token, *pc;
+            char *ajs, *token, *pc;
             const char *token_state = NULL;
             char delimiters[] = ";";
 
             pa_log_debug("RAOP: SETUP");
 
             ajs = pa_xstrdup(pa_headerlist_gets(headers, "Audio-Jack-Status"));
-            trs = pa_xstrdup(pa_headerlist_gets(headers, "Transport"));
 
             if (ajs) {
                 c->jack_type = JACK_TYPE_ANALOG;
@@ -1027,6 +1026,8 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
                 pa_socket_client_unref(sc);
                 sc = NULL;
             } else if (c->protocol == PA_RAOP_PROTOCOL_UDP) {
+                char *trs = pa_xstrdup(pa_headerlist_gets(headers, "Transport"));
+
                 if (trs) {
                     /* Now parse out the server port component of the response. */
                     while ((token = pa_split(trs, delimiters, &token_state))) {
@@ -1040,6 +1041,7 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
                         }
                         pa_xfree(token);
                     }
+                    pa_xfree(trs);
                 } else {
                     pa_log_warn("\"Transport\" missing in RTSP setup response");
                 }
@@ -1062,7 +1064,6 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
 
             pa_rtsp_record(c->rtsp, &c->seq, &c->rtptime);
 
-            pa_xfree(trs);
             pa_xfree(ajs);
             break;
 
-- 
2.7.4



More information about the pulseaudio-discuss mailing list