[PATCH libX11 2/3] XKB: Avoid a possible NULL dereference

Jeremy Huddleston jeremyhu at apple.com
Wed May 4 11:50:17 PDT 2011


XKBGeom.c:191:25: warning: Access to field 'x1' results in a dereference of a null pointer (loaded from variable 'rbounds')
        _XkbCheckBounds(bounds,rbounds->x1,rbounds->y1);
                               ^~~~~~~

Found-by: clang static analyzer
Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
---
 src/xkb/XKBGeom.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/xkb/XKBGeom.c b/src/xkb/XKBGeom.c
index e9e36d0..2365f48 100644
--- a/src/xkb/XKBGeom.c
+++ b/src/xkb/XKBGeom.c
@@ -147,7 +147,7 @@ register int	i;
 XkbShapePtr	shape;
 XkbRowPtr	row;
 XkbDoodadPtr	doodad;
-XkbBoundsPtr	bounds,rbounds=NULL;
+XkbBoundsPtr	bounds,rbounds;
 
     if ((!geom)||(!section))
 	return False;
@@ -186,7 +186,7 @@ XkbBoundsPtr	bounds,rbounds=NULL;
 	    default:
 		tbounds.x1= tbounds.x2= doodad->any.left;
 		tbounds.y1= tbounds.y2= doodad->any.top;
-		break;
+		continue;
 	}
 	_XkbCheckBounds(bounds,rbounds->x1,rbounds->y1);
 	_XkbCheckBounds(bounds,rbounds->x2,rbounds->y2);
-- 
1.7.4.1




More information about the xorg-devel mailing list