Possible bugs due to: warning: XXX may be used uninitialized in this function

Peter Hutterer peter.hutterer at who-t.net
Sun Feb 1 19:00:05 PST 2009


On Mon, Feb 02, 2009 at 03:00:52AM +0100, Tomas Carnecky wrote:
> On 02/02/2009 02:35 AM, Tomas Carnecky wrote:
> > While trying to fix some of the warnings that gcc generates when
> > compiling the xserver, I came across two which appear to be real bugs.
> > Since they don't appear to be trivial to fix, I'm posting them here for
> > further review:
> >
> >
> > Xi/setbmap.c:110 in ProcXSetDeviceButtonMapping()
> > http://cgit.freedesktop.org/xorg/xserver/tree/Xi/setbmap.c#n110
> >
> > 'DeviceIntPtr dev' seems indeed uninitialized and is passed to
> > ApplyPointerMapping().
> 
> commit bc909f71367a02297e725bb5769c2bcadab22395
> Author: Daniel Stone <daniel at fooishbar.org>
> Date:   Tue Aug 12 00:35:56 2008 +0300
> 
> You removed the code that initialized 'dev':
> -    ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
> -    if (ret != Success)
> -       return ret;

yep, looks like it. The patch below should restore it.

>From 4d6ca2d2317336bd684fd850e7fce42e6171049e Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer at who-t.net>
Date: Mon, 2 Feb 2009 12:55:39 +1000
Subject: [PATCH] Xi: initialize the device before applying button map changes.

This part got lost in bc909f71367a0.
Reported by Tomas Carnecky.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xi/setbmap.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/Xi/setbmap.c b/Xi/setbmap.c
index b6f62dd..f29389d 100644
--- a/Xi/setbmap.c
+++ b/Xi/setbmap.c
@@ -101,6 +101,10 @@ ProcXSetDeviceButtonMapping(ClientPtr client)
 			  stuff->map_length + 3) >> 2)
 	return BadLength;
 
+    ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess);
+    if (ret != Success)
+        return ret;
+
     rep.repType = X_Reply;
     rep.RepType = X_SetDeviceButtonMapping;
     rep.length = 0;
-- 
1.6.0.6




More information about the xorg mailing list