[Xcb] Problem with dock windows and libxcb-icccm

David Coppa dcoppa at gmail.com
Wed Mar 10 05:18:51 PST 2010


On Wed, 10 Mar 2010, Jamey Sharp wrote:

> Presumably, because the property isn't present on those windows, which
> would mean the type is None and the format, bytes-after, and length
> are all zero.
> 
> > This causes a floating-point exception in the
> > xcb_get_wm_size_hints_from_reply function, making i3 crash.
> >
> > #0  0x0f5635a4 in xcb_get_wm_size_hints_from_reply (hints=0xcfbc8070,
> >    reply=0x8593fc20) at /usr/xenocara/dist/xcb-util/icccm/icccm.c:442
> > 442       length = xcb_get_property_value_length(reply) / (reply->format / 8);
> 
> Surely it isn't the length being 0, but rather the format, that causes
> this error.
> 
> Since the immediately following if-condition tests that the type and
> format are sane, I'd suggest splitting off the length >= 15 portion of
> the test into its own if-statement and moving the length computation
> in between the two tests.

What about this patch?

diff --git a/icccm/icccm.c b/icccm/icccm.c
index 0206e4b..49d220a 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -444,13 +444,15 @@ xcb_get_wm_size_hints_from_reply(xcb_size_hints_t *hints, xcb_get_property_reply
   if(!reply)
     return 0;
 
-  int length = xcb_get_property_value_length(reply) / (reply->format / 8);
-
   if (!(reply->type == XCB_ATOM_WM_SIZE_HINTS &&
         (reply->format == 8  || reply->format == 16 ||
-         reply->format == 32) &&
-        /* OldNumPropSizeElements = 15 (pre-ICCCM) */
-        length >= 15))
+         reply->format == 32)))
+    return 0;
+
+  int length = xcb_get_property_value_length(reply) / (reply->format / 8);
+
+  /* OldNumPropSizeElements = 15 (pre-ICCCM) */
+  if (!(length >= 15))
     return 0;
 
   memcpy(hints, (xcb_size_hints_t *) xcb_get_property_value (reply),



More information about the Xcb mailing list