[Xcb] segfault on error path in xcb_render_util_query_version

Uli Schlachter psychon at znc.in
Mon Aug 18 01:02:10 PDT 2014


Hi,

On 17.08.2014 22:32, Sam Varshavchik wrote:
[...]
>  for (screens = xcb_setup_roots_iterator(xcb_get_setup(c)); screens.rem; xcb_screen_next(&screens))

Urgh. I guess that bug will be quite common.

Should we make xcb_get_setup() return a fake setup with zero screens, visuals
etc for error connections? Should we perhaps also make it return the "true"
setup for non-static error connections, so that the result doesn't suddenly
change when the connection goes in an error state?

[...]
> I'm calling xcb_render_util_query_version() immediately after xcb_connect()  
> seemingly succeeded, and returned a valid handle.

xcb_connect() will never return NULL. Instead, it will return a connection in an
error state. Check with xcb_connection_has_error(). It should return 0 if
everything is ok.

> To work around this, I added an explicit call to xcb_get_setup(), and a  
> check for a null return value, prior to calling  
> xcb_render_util_query_version().

This does basically the same thing. xcb_get_setup() only returns NULL for
connections in an error state.

Cheers,
Uli
-- 
Q: Because it reverses the logical flow of conversation.
A: Why is putting a reply at the top of the message frowned upon?


More information about the Xcb mailing list