sound: Rework spice_server_playback_get_buffer() error handling

The main goal of this commit is to avoid to dereference 'client' before
it's checked for NULL. This meant splitting one error condition in 2
separate ones.

This also sets default values for the 'frame' and 'num-samples'
out parameters so that we just have to return on error conditions.

Based on a patch from Frediano Ziglio <fziglio@redhat.com>

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Christophe Fergeau 2017-01-05 16:32:45 +01:00
parent e622e09209
commit f5a972fdbf

View File

@ -1166,11 +1166,14 @@ SPICE_GNUC_VISIBLE void spice_server_playback_get_buffer(SpicePlaybackInstance *
uint32_t **frame, uint32_t *num_samples)
{
SndChannelClient *client = sin->st->channel.connection;
PlaybackChannelClient *playback_client = SPICE_CONTAINEROF(client, PlaybackChannelClient, base);
if (!client || !playback_client->free_frames) {
*frame = NULL;
*num_samples = 0;
*frame = NULL;
*num_samples = 0;
if (!client) {
return;
}
PlaybackChannelClient *playback_client = SPICE_CONTAINEROF(client, PlaybackChannelClient, base);
if (!playback_client->free_frames) {
return;
}
spice_assert(client->active);