[Spice-devel] [PATCH 10/15] Fix crash when checking mouse mode

Frediano Ziglio fziglio at redhat.com
Thu Jan 21 08:16:25 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 4222b05..c00285c 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -709,6 +709,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 5b123a5..0a49f3d 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