]> code.delx.au - pulseaudio/commitdiff
module-tunnel: Fix for new protocol versions
authorMaarten Bosmans <mkbosmans@gmail.com>
Sat, 13 Aug 2011 11:43:18 +0000 (13:43 +0200)
committerColin Guthrie <colin@mageia.org>
Mon, 15 Aug 2011 08:41:56 +0000 (09:41 +0100)
The commit 7ebc5033 resulted in segfaults, because format->plist was not allocated.
The solution is not to allocate pa_format_info on the stack, but to properly use pa_format_info_new().
Also a typo regarding pa_tagstruct_putu8 is corrected.

src/modules/module-tunnel.c

index 3efb40b29309654a8e18a68368620cb1f136bb2b..59a4e1ea600bf5a390bfebfd2370e162eaaee1ae 100644 (file)
@@ -1095,7 +1095,7 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command,  uint32_t tag, pa_t
 
     if (u->version >= 21) {
         uint8_t n_formats;
-        pa_format_info format;
+        pa_format_info *format;
 
         if (pa_tagstruct_getu8(t, &n_formats) < 0) { /* no. of formats */
             pa_log("Parse failure");
@@ -1103,10 +1103,13 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command,  uint32_t tag, pa_t
         }
 
         for (uint8_t j = 0; j < n_formats; j++) {
-            if (pa_tagstruct_get_format_info(t, &format)) { /* format info */
+            format = pa_format_info_new();
+            if (pa_tagstruct_get_format_info(t, format)) { /* format info */
+                pa_format_info_free(format);
                 pa_log("Parse failure");
                 goto fail;
             }
+            pa_format_info_free(format);
         }
     }
 
@@ -1209,13 +1212,14 @@ static void sink_input_info_cb(pa_pdispatch *pd, uint32_t command,  uint32_t tag
     }
 
     if (u->version >= 21) {
-        pa_format_info format;
-
-        if (pa_tagstruct_get_format_info(t, &format) < 0) {
+        pa_format_info *format = pa_format_info_new();
 
+        if (pa_tagstruct_get_format_info(t, format) < 0) {
+            pa_format_info_free(format);
             pa_log("Parse failure");
             goto fail;
         }
+        pa_format_info_free(format);
     }
 
     if (!pa_tagstruct_eof(t)) {
@@ -1535,10 +1539,14 @@ static void create_stream_callback(pa_pdispatch *pd, uint32_t command,  uint32_t
     }
 
     if (u->version >= 21) {
-        pa_format_info format;
+        pa_format_info *format = pa_format_info_new();
 
-        if (pa_tagstruct_get_format_info(t, &format) < 0)
+        if (pa_tagstruct_get_format_info(t, format) < 0) {
+            pa_format_info_free(format);
             goto parse_error;
+        }
+
+        pa_format_info_free(format);
     }
 
     if (!pa_tagstruct_eof(t))
@@ -1746,7 +1754,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
 #ifdef TUNNEL_SINK
     if (u->version >= 21) {
         /* We're not using the extended API, so n_formats = 0 and that's that */
-        pa_tagstruct_putu8(t, 0);
+        pa_tagstruct_putu8(reply, 0);
     }
 #endif