On Wed, Sep 17, 2014 at 07:09:53PM -0700, Jason Gerecke wrote:
> If no match is found within the 'while' loop, the value of 'ndevices'
> will be -1 at the point we reach 'if (!ndevices)' since we use the
> post-decrement rather than pre-decrement operator. In addition to
> never producing the expected error message, this also results in a
> NULL dereference immediately afterwards.
> 
> Signed-off-by: Jason Gerecke <killert...@gmail.com>
> ---
>  tools/xsetwacom.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
> index 276f7dd..5a5173d 100644
> --- a/tools/xsetwacom.c
> +++ b/tools/xsetwacom.c
> @@ -1758,7 +1758,7 @@ static void get_mode(Display *dpy, XDevice *dev, 
> param_t* param, int argc, char
>       XValuatorInfoPtr v;
>  
>       info = XListInputDevices(dpy, &ndevices);
> -     while(ndevices--)
> +     while(--ndevices)

that won't work for 0 devices, which admittedly can't happen with current
servers. Ok with this change, if you add the matching 
    if (ndevices > 0)

Cheers,
  Peter


>       {
>               d = &info[ndevices];
>               if (d->id == dev->device_id)
> -- 
> 2.1.0
> 
> 
> ------------------------------------------------------------------------------
> Want excitement?
> Manually upgrade your production database.
> When you want reliability, choose Perforce
> Perforce version control. Predictably reliable.
> http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
> _______________________________________________
> Linuxwacom-devel mailing list
> Linuxwacom-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
> 

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to