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) { 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