[Xcb-commit] icccm

Julien Danjou jdanjou at kemper.freedesktop.org
Tue Oct 20 09:11:26 PDT 2009


 icccm/icccm.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

New commits:
commit d5b5d682465bd3196105df86d6df9fcde9518e6c
Author: Julien Danjou <julien at danjou.info>
Date:   Tue Oct 20 18:10:12 2009 +0200

    icccm: fix reply->format check
    
    We need to check reply->format before using it, or we can end up
    dividing by 0.
    
    Signed-off-by: Julien Danjou <julien at danjou.info>

diff --git a/icccm/icccm.c b/icccm/icccm.c
index 51132a9..18c2cf2 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -633,15 +633,13 @@ uint8_t
 xcb_get_wm_hints_from_reply(xcb_wm_hints_t *hints,
                             xcb_get_property_reply_t *reply)
 {
-  if(!reply)
+  if(!reply || reply->type != WM_HINTS || reply->format != 32)
     return 0;
 
   int length = xcb_get_property_value_length(reply);
   int num_elem = length / (reply->format / 8);
 
-  if (reply->type != WM_HINTS
-      || reply->format != 32
-      || num_elem < XCB_NUM_WM_HINTS_ELEMENTS - 1)
+  if(num_elem < XCB_NUM_WM_HINTS_ELEMENTS - 1)
     return 0;
 
   memcpy(hints, (xcb_size_hints_t *) xcb_get_property_value(reply), length);


More information about the xcb-commit mailing list