diff --git a/icccm/icccm.c b/icccm/icccm.c
index 67270d354e950fe92a8e363fc754c092303752f9..776c299fdb136e63d79755cee56abc3183b4ecf4 100644
--- a/icccm/icccm.c
+++ b/icccm/icccm.c
@@ -694,18 +694,10 @@ xcb_get_wm_protocols_unchecked(xcb_connection_t *c,
 }
 
 uint8_t
-xcb_get_wm_protocols_reply(xcb_connection_t *c,
-                           xcb_get_property_cookie_t cookie,
-                           xcb_get_wm_protocols_reply_t *protocols,
-                           xcb_generic_error_t **e)
+xcb_get_wm_protocols_from_reply(xcb_get_property_reply_t *reply, xcb_get_wm_protocols_reply_t *protocols)
 {
-  xcb_get_property_reply_t *reply = xcb_get_property_reply(c, cookie, e);
-
   if(!reply || reply->type != ATOM || reply->format != 32)
-  {
-    free(reply);
     return 0;
-  }
 
   protocols->_reply = reply;
   protocols->atoms_len = xcb_get_property_value_length(protocols->_reply) /  (reply->format / 8);
@@ -714,6 +706,19 @@ xcb_get_wm_protocols_reply(xcb_connection_t *c,
   return 1;
 }
 
+uint8_t
+xcb_get_wm_protocols_reply(xcb_connection_t *c,
+                           xcb_get_property_cookie_t cookie,
+                           xcb_get_wm_protocols_reply_t *protocols,
+                           xcb_generic_error_t **e)
+{
+  xcb_get_property_reply_t *reply = xcb_get_property_reply(c, cookie, e);
+  uint8_t ret = xcb_get_wm_protocols_from_reply(reply, protocols);
+  if(!ret)
+      free(reply);
+  return ret;
+}
+
 void
 xcb_get_wm_protocols_reply_wipe(xcb_get_wm_protocols_reply_t *protocols)
 {
diff --git a/icccm/xcb_icccm.h b/icccm/xcb_icccm.h
index 5358d899f7b95d0c8b11099c9fc836ad842ed6de..938fecb4baa43062f20941401c7c249a10fb6e8c 100644
--- a/icccm/xcb_icccm.h
+++ b/icccm/xcb_icccm.h
@@ -869,6 +869,17 @@ xcb_get_property_cookie_t xcb_get_wm_protocols_unchecked(xcb_connection_t *c,
                                                          xcb_window_t window,
                                                          xcb_atom_t wm_protocol_atom);
 
+/**
+ * @brief Fill the given structure with the WM_PROTOCOLS property of a window.
+ * @param reply The reply of the GetProperty request.
+ * @param protocols WM_PROTOCOLS property value.
+ * @return Return 1 on success, 0 otherwise.
+ *
+ * protocols structure members should be freed by
+ * xcb_get_wm_protocols_reply_wipe().
+ */
+uint8_t xcb_get_wm_protocols_from_reply(xcb_get_property_reply_t *reply,
+                                        xcb_get_wm_protocols_reply_t *protocols);
 /**
  * @brief Fill the given structure with the WM_PROTOCOLS property of a window.
  * @param c The connection to the X server.