From: RĂ©mi Duraffort Date: Wed, 2 Jan 2008 11:36:40 +0000 (+0000) Subject: Limit the mouse-x and mouse-y beetween 0 and p_vout->fmt_in.i_visible_(width\|height... X-Git-Tag: 0.9.0-test0~3719 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b55763db1328128715cdb9a4ce8063f7d3a8f2b4;p=vlc Limit the mouse-x and mouse-y beetween 0 and p_vout->fmt_in.i_visible_(width\|height) to avoid unsigned overflow. Feel free to revert if this commit is stupid. --- diff --git a/modules/video_output/x11/xcommon.c b/modules/video_output/x11/xcommon.c index 2061a8e4ea..9874bcd869 100644 --- a/modules/video_output/x11/xcommon.c +++ b/modules/video_output/x11/xcommon.c @@ -1363,13 +1363,30 @@ static int ManageVideo( vout_thread_t *p_vout ) p_vout->p_sys->p_win->i_height, &i_x, &i_y, &i_width, &i_height ); + /* Compute the x coordinate and check if the value is + in [0,p_vout->fmt_in.i_visible_width] */ val.i_int = ( xevent.xmotion.x - i_x ) * p_vout->fmt_in.i_visible_width / i_width + p_vout->fmt_in.i_x_offset; + + if( (int)(xevent.xmotion.x - i_x) < 0 ) + val.i_int = 0; + else if( (unsigned int)val.i_int > p_vout->fmt_in.i_visible_width ) + val.i_int = p_vout->fmt_in.i_visible_width; + var_Set( p_vout, "mouse-x", val ); + + /* compute the y coordinate and check if the value is + in [0,p_vout->fmt_in.i_visible_height] */ val.i_int = ( xevent.xmotion.y - i_y ) * p_vout->fmt_in.i_visible_height / i_height + p_vout->fmt_in.i_y_offset; + + if( (int)(xevent.xmotion.y - i_y) < 0 ) + val.i_int = 0; + else if( (unsigned int)val.i_int > p_vout->fmt_in.i_visible_height ) + val.i_int = p_vout->fmt_in.i_visible_height; + var_Set( p_vout, "mouse-y", val ); val.b_bool = VLC_TRUE;