[Spice-devel] [spice-gtk] Avoid to access array with negative numbers

Frediano Ziglio fziglio at redhat.com
Wed Mar 23 15:28:17 UTC 2016


---
 src/spice-widget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 19753e7..d2fd789 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -1549,7 +1549,7 @@ static int button_gdk_to_spice(int gdk)
         [ 5 ] = SPICE_MOUSE_BUTTON_DOWN,
     };
 
-    if (gdk < SPICE_N_ELEMENTS(map)) {
+    if (gdk >= 0 && gdk < SPICE_N_ELEMENTS(map)) {
         return map [ gdk ];
     }
     return 0;
-- 
2.5.5



More information about the Spice-devel mailing list