[pulseaudio-discuss] [PATCH 5/6] sink-input: Avoid potential NULL dereference

Tanu Kaskinen tanuk at iki.fi
Fri Aug 19 15:45:55 UTC 2016


On Thu, 2016-08-18 at 18:17 +0200, Peter Meerwald-Stadler wrote:
> if data->sink is NULL, pa_sink_input_new_data_set_sink() may fail to set data->sink;
> the false retval is ignored, leading to a NULL dereference in pa_sink_get_state(data->sink) below
> 
> CID 1323591
> ---
>  src/pulsecore/sink-input.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
> index 435e63e..36f4aa8 100644
> --- a/src/pulsecore/sink-input.c
> +++ b/src/pulsecore/sink-input.c
> @@ -329,7 +329,8 @@ int pa_sink_input_new(
>      if (!data->sink) {
>          pa_sink *sink = pa_namereg_get(core, NULL, PA_NAMEREG_SINK);
>          pa_return_val_if_fail(sink, -PA_ERR_NOENTITY);
> -        pa_sink_input_new_data_set_sink(data, sink, false);
> +        if (!pa_sink_input_new_data_set_sink(data, sink, false))
> +            return -PA_ERR_NOTSUPPORTED;
>      }
>  
>      /* If something didn't pick a format for us, pick the top-most format since

Same comment as for the source-output patch.

-- 
Tanu


More information about the pulseaudio-discuss mailing list