]> code.delx.au - pulseaudio/commitdiff
sink-input, source-output: Don't assume that proplist has been initialized in free()
authorTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Thu, 14 Nov 2013 08:53:44 +0000 (10:53 +0200)
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Thu, 14 Nov 2013 13:17:17 +0000 (15:17 +0200)
It's bad form to assume in free() that any member of the struct has
been initialized. I ran into problems with this when I reordered
things in pa_sink_input_new() and pa_source_output_new().

src/pulsecore/sink-input.c
src/pulsecore/source-output.c

index 5164d27635d1664836bd43ebfc4c87f82c2076be..b002467a602de3e08967b49eb3864aef41fd83c5 100644 (file)
@@ -745,7 +745,8 @@ static void sink_input_free(pa_object *o) {
     if (PA_SINK_INPUT_IS_LINKED(i->state))
         pa_sink_input_unlink(i);
 
-    pa_log_info("Freeing input %u \"%s\"", i->index, pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_MEDIA_NAME)));
+    pa_log_info("Freeing input %u \"%s\"", i->index,
+                i->proplist ? pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_MEDIA_NAME)) : "");
 
     /* Side note: this function must be able to destruct properly any
      * kind of sink input in any state, even those which are
index b158f14f41cb9e9ce193aeb9b8c5c140734f3cef..088dd0c0f4b613dd990ab7442a4d3a1ab41388e0 100644 (file)
@@ -630,7 +630,8 @@ static void source_output_free(pa_object* mo) {
     if (PA_SOURCE_OUTPUT_IS_LINKED(o->state))
         pa_source_output_unlink(o);
 
-    pa_log_info("Freeing output %u \"%s\"", o->index, pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_MEDIA_NAME)));
+    pa_log_info("Freeing output %u \"%s\"", o->index,
+                o->proplist ? pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_MEDIA_NAME)) : "");
 
     if (o->thread_info.delay_memblockq)
         pa_memblockq_free(o->thread_info.delay_memblockq);