[Spice-devel] [spice-server 06/17] sound: Don't dereference pointer before NULL check
Christophe Fergeau
cfergeau at redhat.com
Wed Jan 11 08:48:20 UTC 2017
Based on a patch from Frediano Ziglio <fziglio at redhat.com>
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
server/sound.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/server/sound.c b/server/sound.c
index 7ebea90..1eab75b 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -1125,11 +1125,11 @@ SPICE_GNUC_VISIBLE void spice_server_playback_start(SpicePlaybackInstance *sin)
SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
{
SndChannelClient *client = sin->st->channel.connection;
- PlaybackChannelClient *playback_client = SPICE_CONTAINEROF(client, PlaybackChannelClient, base);
sin->st->channel.active = 0;
if (!client)
return;
+ PlaybackChannelClient *playback_client = SPICE_CONTAINEROF(client, PlaybackChannelClient, base);
spice_assert(client->active);
reds_enable_mm_time(snd_channel_get_server(client));
client->active = FALSE;
@@ -1383,11 +1383,11 @@ SPICE_GNUC_VISIBLE void spice_server_record_set_mute(SpiceRecordInstance *sin, u
static void snd_record_start(SndChannel *channel)
{
SndChannelClient *client = channel->connection;
- RecordChannelClient *record_client = SPICE_CONTAINEROF(client, RecordChannelClient, base);
channel->active = 1;
if (!client)
return;
+ RecordChannelClient *record_client = SPICE_CONTAINEROF(client, RecordChannelClient, base);
spice_assert(!client->active);
record_client->read_pos = record_client->write_pos = 0; //todo: improve by
//stream generation
@@ -1426,13 +1426,13 @@ SPICE_GNUC_VISIBLE uint32_t spice_server_record_get_samples(SpiceRecordInstance
uint32_t *samples, uint32_t bufsize)
{
SndChannelClient *client = sin->st->channel.connection;
- RecordChannelClient *record_client = SPICE_CONTAINEROF(client, RecordChannelClient, base);
uint32_t read_pos;
uint32_t now;
uint32_t len;
if (!client)
return 0;
+ RecordChannelClient *record_client = SPICE_CONTAINEROF(client, RecordChannelClient, base);
spice_assert(client->active);
if (record_client->write_pos < RECORD_SAMPLES_SIZE / 2) {
--
2.9.3
More information about the Spice-devel
mailing list