diff --git a/src/conn.c b/src/conn.c
index 39833c890fa463579e066e71cb3389dbc6dc78a5..1b21d172c45551487a4ed98a1d10cf575dbf72d1 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;