[pulseaudio-discuss] [PATCH] Don't crash if pa_stream_peek returns NULL

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Tue Oct 28 02:33:41 PDT 2014


On Wed, 2014-10-22 at 20:38 -0300, Felipe Sateler wrote:
> From: Christer Stenbrenden <christer at uggwar.net>
> 
> pa_stream_peek can return NULL if either the buffer is empty or if it
> has a hole. In either case we need to avoid derefencing the data
> pointer. Additionally, if there is a hole, we need to call pa_stream_drop,
> if the buffer is empty we should not call it.
> 
> Thanks to Christer Stenbrenden for the initial patch.
> BugLink: https://bugs.debian.org/735898
> ---
>  src/mainwindow.cc | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/src/mainwindow.cc b/src/mainwindow.cc
> index 5d205fb..ff9ec52 100644
> --- a/src/mainwindow.cc
> +++ b/src/mainwindow.cc
> @@ -493,6 +493,14 @@ static void read_callback(pa_stream *s, size_t length, void *userdata) {
>          return;
>      }
>  
> +    if (!data) {
> +        // NULL data means either a hole or empty buffer.
> +	// Only drop the stream when there is a hole (length > 0)
> +        if (length)
> +            pa_stream_drop(s);
> +        return;
> +    }
> +
>      assert(length > 0);
>      assert(length % sizeof(float) == 0);
>  

Thanks! Applied.

-- 
Tanu



More information about the pulseaudio-discuss mailing list