[pulseaudio-discuss] [PATCH] sink-input, source-output: Don't assume that proplist has been initialized in free()
David Henningsson
david.henningsson at canonical.com
Thu Nov 14 01:54:30 PST 2013
On 11/14/2013 09:53 AM, Tanu Kaskinen wrote:
> 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().
Looks good. Acked.
> ---
> src/pulsecore/sink-input.c | 3 ++-
> src/pulsecore/source-output.c | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
> index 5164d27..b002467 100644
> --- a/src/pulsecore/sink-input.c
> +++ b/src/pulsecore/sink-input.c
> @@ -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
> diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
> index b158f14..088dd0c 100644
> --- a/src/pulsecore/source-output.c
> +++ b/src/pulsecore/source-output.c
> @@ -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);
>
--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
More information about the pulseaudio-discuss
mailing list