[Spice-devel] [PATCH spice-server 2/2] server: handle red_channel_client_create returning NULL

Yonit Halperin yhalperi at redhat.com
Sun May 20 03:31:38 PDT 2012


---
 server/inputs_channel.c    |    3 +++
 server/main_channel.c      |    2 +-
 server/red_tunnel_worker.c |    4 +++-
 server/red_worker.c        |    3 +++
 server/smartcard.c         |    3 +++
 server/snd_worker.c        |    3 +++
 6 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index ad247f4..e14e995 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -502,6 +502,9 @@ static void inputs_connect(RedChannel *channel, RedClient *client,
                                                           stream,
                                                           num_common_caps, common_caps,
                                                           num_caps, caps);
+    if (!icc) {
+        return;
+    }
     icc->motion_count = 0;
     inputs_pipe_add_init(&icc->base);
 }
diff --git a/server/main_channel.c b/server/main_channel.c
index 713f121..ace24ff 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -998,7 +998,7 @@ static MainChannelClient *main_channel_client_create(MainChannel *main_chan, Red
                              red_channel_client_create(sizeof(MainChannelClient), &main_chan->base,
                                                        client, stream, num_common_caps,
                                                        common_caps, num_caps, caps);
-
+    spice_assert(mcc != NULL);
     mcc->connection_id = connection_id;
     mcc->bitrate_per_sec = ~0;
 #ifdef RED_STATISTICS
diff --git a/server/red_tunnel_worker.c b/server/red_tunnel_worker.c
index 384c36d..12f3106 100644
--- a/server/red_tunnel_worker.c
+++ b/server/red_tunnel_worker.c
@@ -3452,7 +3452,9 @@ static void handle_tunnel_channel_link(RedChannel *channel, RedClient *client,
     tcc = (TunnelChannelClient*)red_channel_client_create(sizeof(TunnelChannelClient),
                                                           channel, client, stream,
                                                           0, NULL, 0, NULL);
-
+    if (!tcc) {
+        return;
+    }
     tcc->worker = worker;
     tcc->worker->channel_client = tcc;
     net_slirp_set_net_interface(&worker->tunnel_interface.base);
diff --git a/server/red_worker.c b/server/red_worker.c
index dd00bff..3616d0f 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9769,6 +9769,9 @@ static CommonChannelClient *common_channel_client_create(int size,
     RedChannelClient *rcc =
         red_channel_client_create(size, &common->base, client, stream,
                                   num_common_caps, common_caps, num_caps, caps);
+    if (!rcc) {
+        return NULL;
+    }
     CommonChannelClient *common_cc = (CommonChannelClient*)rcc;
     common_cc->worker = common->worker;
     common_cc->id = common->worker->id;
diff --git a/server/smartcard.c b/server/smartcard.c
index eb2823a..8ded142 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -500,6 +500,9 @@ static void smartcard_connect(RedChannel *channel, RedClient *client,
     rcc = red_channel_client_create(sizeof(RedChannelClient), channel, client, stream,
                                     num_common_caps, common_caps,
                                     num_caps, caps);
+    if (!rcc) {
+        return;
+    }
     red_channel_client_ack_zero_messages_window(rcc);
 }
 
diff --git a/server/snd_worker.c b/server/snd_worker.c
index caffe67..3599c6f 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -975,6 +975,9 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
                                                               client,
                                                               num_common_caps, common_caps,
                                                               num_caps, caps);
+    if (!channel->channel_client) {
+        goto error2;
+    }
     return channel;
 
 error2:
-- 
1.7.7.6



More information about the Spice-devel mailing list