diff --git a/src/x11/xprops.c b/src/x11/xprops.c index be3882455..e3bd931f0 100644 --- a/src/x11/xprops.c +++ b/src/x11/xprops.c @@ -194,6 +194,7 @@ async_get_property_finish (xcb_connection_t *xcb_conn, { xcb_get_property_reply_t *reply; xcb_generic_error_t *error; + int length; reply = xcb_get_property_reply (xcb_conn, cookie, &error); if (error) @@ -209,8 +210,15 @@ async_get_property_finish (xcb_connection_t *xcb_conn, results->prop = NULL; if (results->type != None) - results->prop = g_memdup (xcb_get_property_value (reply), - xcb_get_property_value_length (reply)); + { + length = xcb_get_property_value_length (reply); + /* Leave room for a trailing '\0' since xcb doesn't return null-terminated + * strings + */ + results->prop = g_malloc (length + 1); + memcpy (results->prop, xcb_get_property_value (reply), length); + results->prop[length] = '\0'; + } free (reply); return (results->prop != NULL);