Skip to content

Commit 240e8af

Browse files
committed
module: guard against null return from xcb_get_extension_data()
see comment for details... this probably doesn't *really* occur in the wild very much, but we uncovered it in our parallel testing, and didn't quite get it fixed in d3c25ee ("module: be less strange about extension key lifetimes") (although that was probably also a bug and a nice cleanup anyway at net negative lines, this is likely the real source of the seg fault). Signed-off-by: Tycho Andersen <[email protected]>
1 parent f1fcbb5 commit 240e8af

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

module/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,13 @@ def _init_x(self):
549549
def _setup_extensions(self):
550550
for key, (_, events, errors) in extensions.items():
551551
reply = lib.xcb_get_extension_data(self._conn, key.c_key)
552+
# although it does not say so in the man page,
553+
# xcb_get_extension_data() will return NULL if the connection has
554+
# an error. let's guard against this, and do our own connection
555+
# checking in this case.
556+
if reply == ffi.NULL:
557+
self.invalid()
558+
raise XcffibException("uh oh... connection valid but xcb_get_extension_data() returned NULL?")
552559
self._event_offsets.add(reply.first_event, reply.major_opcode, events)
553560
self._error_offsets.add(reply.first_error, reply.major_opcode, errors)
554561

0 commit comments

Comments
 (0)