[Spice-commits] server/cursor-channel.c server/dcc-send.c server/stream.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Wed Aug 30 14:58:36 UTC 2017


 server/cursor-channel.c |    3 ++-
 server/dcc-send.c       |   11 ++++++++---
 server/stream.c         |    3 ++-
 3 files changed, 12 insertions(+), 5 deletions(-)

New commits:
commit 20676792a8222c9499c79be8cac39341a03b3a3c
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri May 20 18:07:34 2016 +0100

    Avoid to access data before a NULL check
    
    If you are testing for NULL data this means that variable could be
    NULL so avoid to access before the check to make sure the check is hit.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 63d6886d..5ece576c 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -182,11 +182,12 @@ static void cursor_pipe_item_free(RedPipeItem *base)
 static void red_marshall_cursor_init(CursorChannelClient *ccc, SpiceMarshaller *base_marshaller,
                                      RedPipeItem *pipe_item)
 {
+    spice_assert(ccc);
+
     CursorChannel *cursor_channel;
     RedChannelClient *rcc = RED_CHANNEL_CLIENT(ccc);
     SpiceMsgCursorInit msg;
 
-    spice_assert(rcc);
     cursor_channel = CURSOR_CHANNEL(red_channel_client_get_channel(rcc));
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INIT);
diff --git a/server/dcc-send.c b/server/dcc-send.c
index 5a24e693..8e91b8fb 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -1922,8 +1922,8 @@ static void red_marshall_image(RedChannelClient *rcc,
                                SpiceMarshaller *m,
                                RedImageItem *item)
 {
-    DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
-    DisplayChannel *display = DCC_TO_DC(dcc);
+    DisplayChannelClient *dcc;
+    DisplayChannel *display;
     SpiceImage red_image;
     SpiceBitmap bitmap;
     SpiceChunks *chunks;
@@ -1932,7 +1932,12 @@ static void red_marshall_image(RedChannelClient *rcc,
     SpiceMarshaller *src_bitmap_out, *mask_bitmap_out;
     SpiceMarshaller *bitmap_palette_out, *lzplt_palette_out;
 
-    spice_assert(rcc && display && item);
+    spice_assert(rcc && item);
+
+    dcc = DISPLAY_CHANNEL_CLIENT(rcc);
+
+    display = DCC_TO_DC(dcc);
+    spice_assert(display);
 
     QXL_SET_IMAGE_ID(&red_image, QXL_IMAGE_GROUP_RED, display_channel_generate_uid(display));
     red_image.descriptor.type = SPICE_IMAGE_TYPE_BITMAP;
diff --git a/server/stream.c b/server/stream.c
index f74a1385..0148d1ed 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -772,9 +772,10 @@ void stream_agent_stop(StreamAgent *agent)
 
 static void red_upgrade_item_free(RedPipeItem *base)
 {
+    g_return_if_fail(base != NULL);
+
     RedUpgradeItem *item = SPICE_UPCAST(RedUpgradeItem, base);
 
-    g_return_if_fail(item != NULL);
     g_return_if_fail(item->base.refcount == 0);
 
     drawable_unref(item->drawable);


More information about the Spice-commits mailing list