修复 get_window_tag 函数内存未释放 bug

This commit is contained in:
2025-09-05 23:07:31 +08:00
parent 9dfcf62c3c
commit b40f499e7b

View File

@@ -182,14 +182,16 @@ bool get_window_tag(xcb_window_t window, client_tag_info_t *client_info) {
XCB_ATOM_CARDINAL, 0, 2); XCB_ATOM_CARDINAL, 0, 2);
xcb_get_property_reply_t *reply = xcb_get_property_reply(conn, cookie, NULL); xcb_get_property_reply_t *reply = xcb_get_property_reply(conn, cookie, NULL);
int length = xcb_get_property_value_length(reply); int length = xcb_get_property_value_length(reply);
if (length >= 2) { bool result = length >= 2;
if (result) {
uint32_t *data = xcb_get_property_value(reply); uint32_t *data = xcb_get_property_value(reply);
client_info->tags = data[0]; client_info->tags = data[0];
client_info->monitor_index = data[1]; client_info->monitor_index = data[1];
return true;
} else {
return false;
} }
free(reply);
return result;
} }
void set_window_tag(xcb_window_t window, client_tag_info_t *client_info) { void set_window_tag(xcb_window_t window, client_tag_info_t *client_info) {