[Spice-devel] [PATCH 11/16] Fix crash when checking mouse mode

Frediano Ziglio fziglio at redhat.com
Wed Jan 27 04:48:37 PST 2016


From: Jonathon Jongsma <jjongsma at redhat.com>

Since the mouse mode is now stored in the inputs channel, we were
crashing when somebody was calling this API before the inputs channel
was created.
---
 server/inputs-channel.c | 1 +
 server/reds.c           | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 9f33f0d..e28b4b0 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -704,6 +704,7 @@ int inputs_channel_set_tablet(InputsChannel *inputs, SpiceTabletInstance *tablet
 
 int inputs_channel_has_tablet(InputsChannel *inputs)
 {
+    spice_return_val_if_fail(inputs != NULL, FALSE);
     return !!inputs->tablet;
 }
 
diff --git a/server/reds.c b/server/reds.c
index f35b602..3f2a132 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -613,7 +613,9 @@ static void reds_update_mouse_mode(RedsState *reds)
     int allowed = 0;
     int qxl_count = red_dispatcher_qxl_count();
 
-    if ((agent_mouse && vdagent) || (inputs_channel_has_tablet(reds->inputs_channel) && qxl_count == 1)) {
+    if ((agent_mouse && vdagent) ||
+        ((reds->inputs_channel && inputs_channel_has_tablet(reds->inputs_channel)) &&
+         qxl_count == 1)) {
         allowed = reds->dispatcher_allows_client_mouse;
     }
     if (allowed == reds->is_client_mouse_allowed) {
-- 
2.4.3



More information about the Spice-devel mailing list