[Spice-commits] src/channel-display.c

Christophe Fergau teuf at kemper.freedesktop.org
Wed Nov 4 03:13:52 PST 2015


 src/channel-display.c |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

New commits:
commit 64319761e16abeac6572b8f3a33c5d0193f7dda4
Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Fri Oct 30 12:17:30 2015 +0100

    spice-gtk: Fix error handling in stream_get_current_frame()
    
    *data must always be set to NULL on error.
    
    Signed-off-by: Francois Gouget <fgouget at codeweavers.com>

diff --git a/src/channel-display.c b/src/channel-display.c
index 46e9829..9e42dd9 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -1081,20 +1081,21 @@ uint32_t stream_get_current_frame(display_stream *st, uint8_t **data)
         return 0;
     }
 
-    if (spice_msg_in_type(st->msg_data) == SPICE_MSG_DISPLAY_STREAM_DATA) {
+    switch (spice_msg_in_type(st->msg_data)) {
+    case SPICE_MSG_DISPLAY_STREAM_DATA: {
         SpiceMsgDisplayStreamData *op = spice_msg_in_parsed(st->msg_data);
-
         *data = op->data;
         return op->data_size;
-    } else {
+    }
+    case SPICE_MSG_DISPLAY_STREAM_DATA_SIZED: {
         SpiceMsgDisplayStreamDataSized *op = spice_msg_in_parsed(st->msg_data);
-
-        g_return_val_if_fail(spice_msg_in_type(st->msg_data) ==
-                             SPICE_MSG_DISPLAY_STREAM_DATA_SIZED, 0);
         *data = op->data;
         return op->data_size;
-   }
-
+    }
+    default:
+        *data = NULL;
+        g_return_val_if_reached(0);
+    }
 }
 
 G_GNUC_INTERNAL


More information about the Spice-commits mailing list