diff --git a/icccm/icccm.c b/icccm/icccm.c
index cf22a25..c8223a2 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -538,16 +538,13 @@ xcb_get_wm_size_hints (xcb_connection_t *c,
 	     (rep->format == 32)) &&
 	    (rep->value_len >= 15)) /* OldNumPropSizeElements = 15 (pre-ICCCM) */
 	{
-                char *prop;
-	        long  length;
+		/* Copy at a maximum the size of xcb_size_hints_t structure (is
+		 * it really useful?) */
+		long value_size = (xcb_get_property_value_length(rep) * rep->format) >> 3;
+		const long max_size = sizeof(xcb_size_hints_t);
 
-		length = xcb_get_property_value_length (rep);
-		/* FIXME: in GetProp.c of xcl, one move the memory.
-		 * Should we do that too ? */
-		prop = (char *)malloc(sizeof(char)*length);
-		memcpy(prop, xcb_get_property_value (rep), length);
-		prop[length] = '\0';
-		hints = (xcb_size_hints_t *)strdup (prop);
+		memcpy(hints, (xcb_size_hints_t *) xcb_get_property_value(rep),
+		       (value_size > max_size ? max_size : value_size));
 
 		*supplied = (USPosition | USSize   |
 			     PPosition  | PSize    |
@@ -568,7 +565,7 @@ xcb_get_wm_size_hints (xcb_connection_t *c,
 		return 1;
 	}
 
-	hints = NULL;
+	free (hints);
 	free (rep);
 
 	return 0;

