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

Pavel Grunt pgrunt at redhat.com
Wed Mar 23 15:34:32 UTC 2016


Hi,

according to GdkEventButton documentation [0] the 'button' is guint so
the button_gdk_to_spice() should take guint instead of int.

Pavel

[0] https://developer.gnome.org/gdk3/stable/gdk3-Event-Structures.html#
GdkEventButton

On Wed, 2016-03-23 at 15:28 +0000, Frediano Ziglio wrote:
> ---
>  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;


More information about the Spice-devel mailing list