[PATCH] xcb_ewmh_get_wm_icon_reply: Fix crash on error
Uli Schlachter
psychon at znc.in
Fri Mar 11 04:21:46 PST 2011
When the GetProperty request fails due to an error,
xcb_ewmh_get_wm_icon_from_reply will be called with a NULL pointer for the
reply. This function would then call xcb_get_property_value_length on this NULL
pointer which caused a crash.
Fix this by moving the NULL-pointer check before the call to value_length().
Signed-off-by: Uli Schlachter <psychon at znc.in>
---
ewmh/ewmh.c.m4 | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/ewmh/ewmh.c.m4 b/ewmh/ewmh.c.m4
index 4a609b6..02d43f5 100644
--- a/ewmh/ewmh.c.m4
+++ b/ewmh/ewmh.c.m4
@@ -1176,13 +1176,11 @@ xcb_ewmh_get_wm_icon_from_reply(xcb_ewmh_get_wm_icon_reply_t *wm_icon,
xcb_get_property_reply_t *r)
{
uint8_t num_icons = 0;
- uint32_t r_value_len = xcb_get_property_value_length(r);
- if(!r || r->type != XCB_ATOM_CARDINAL || r->format != 32 ||
- r_value_len <= (sizeof(uint32_t) * 2))
+ if(!r || r->type != XCB_ATOM_CARDINAL || r->format != 32)
return 0;
-
+ uint32_t r_value_len = xcb_get_property_value_length(r);
uint32_t *r_value = (uint32_t *) xcb_get_property_value(r);
- if(!r_value)
+ if(r_value_len <= (sizeof(uint32_t) * 2) || !r_value)
return 0;
memset(wm_icon, 0, sizeof(xcb_ewmh_get_wm_icon_reply_t));
--
1.7.2.3
--------------000603030909030800090802--
More information about the Xcb
mailing list