[PATCH:libX11 2/2] _XkbReadGeomOverlay: check for NULL first, then use pointer

Alan Coopersmith alan.coopersmith at oracle.com
Thu Dec 26 09:28:39 PST 2013


Flagged by cppcheck 1.62:
[lib/libX11/src/xkb/XKBGeom.c:479] -> [lib/libX11/src/xkb/XKBGeom.c:480]:
 (warning) Possible null pointer dereference: row - otherwise it is
 redundant to check it against null.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/xkb/XKBGeom.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/xkb/XKBGeom.c b/src/xkb/XKBGeom.c
index 6a1c74a..feaaab6 100644
--- a/src/xkb/XKBGeom.c
+++ b/src/xkb/XKBGeom.c
@@ -476,9 +476,9 @@ _XkbReadGeomOverlay(XkbReadBufferPtr buf,
         if (rowWire == NULL)
             return BadLength;
         row = XkbAddGeomOverlayRow(ol, rowWire->rowUnder, rowWire->nKeys);
-        row->row_under = rowWire->rowUnder;
         if (!row)
             return BadAlloc;
+        row->row_under = rowWire->rowUnder;
         if (rowWire->nKeys < 1)
             continue;
         keyWire = (xkbOverlayKeyWireDesc *)
-- 
1.7.9.2



More information about the xorg-devel mailing list