[Xcb] [PATCH:xpyb] xpybConn_call should ensure ext is not NULL before using it

Alan Coopersmith alan.coopersmith at oracle.com
Sun Aug 18 16:50:28 PDT 2013


Found by Oracle's Parfait 1.2 static analyzer:
   Null pointer dereference (CWE 476): Read from null pointer ext
        at line 322 of /export/alanc/X.Org/amd64-parfait/xcb/xpyb/src/conn.c
            in function 'xpybConn_call'.
          Function xpybConn_load_ext may return constant 'NULL' at line 141,
              called at line 321.
          Null pointer introduced at line 141 in function 'xpybConn_load_ext'.

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

diff --git a/src/conn.c b/src/conn.c
index 39833c8..1b21d17 100644
--- a/src/conn.c
+++ b/src/conn.c
@@ -319,7 +319,7 @@ xpybConn_call(xpybConn *self, PyObject *args, PyObject *kw)
 
     /* Check our dictionary of cached values */
     ext = xpybConn_load_ext(self, key);
-    if (!ext->present) {
+    if (ext != NULL && !ext->present) {
 	PyErr_SetString(xpybExcept_ext, "Extension not present on server.");
 	Py_DECREF(ext);
 	return NULL;
-- 
1.7.9.2



More information about the Xcb mailing list