Skip to content

Memory leak at demo_create_xcb_window() #1213

@cfnptr

Description

@cfnptr

Based on xcb docs we should free reply after calling xcb_intern_atom_reply().

Vulkan-Tools/cube/cube.c

Lines 3002 to 3020 in 90bf5bc

char *name = "Vkcube X11";
xcb_intern_atom_cookie_t net_wm_name_cookie = xcb_intern_atom(demo->connection, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME");
xcb_intern_atom_cookie_t utf8_string_cookie = xcb_intern_atom(demo->connection, 0, strlen("UTF8_STRING"), "UTF8_STRING");
xcb_intern_atom_reply_t *net_wm_name_reply = xcb_intern_atom_reply(demo->connection, net_wm_name_cookie, NULL);
xcb_intern_atom_reply_t *utf8_string_reply = xcb_intern_atom_reply(demo->connection, utf8_string_cookie, NULL);
xcb_change_property(demo->connection, XCB_PROP_MODE_REPLACE,
demo->xcb_window, net_wm_name_reply->atom,
utf8_string_reply->atom, 8, strlen(name), name);
/* Magic code that will send notification when window is destroyed */
xcb_intern_atom_cookie_t cookie = xcb_intern_atom(demo->connection, 1, 12, "WM_PROTOCOLS");
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(demo->connection, cookie, 0);
xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom(demo->connection, 0, 16, "WM_DELETE_WINDOW");
demo->atom_wm_delete_window = xcb_intern_atom_reply(demo->connection, cookie2, 0);
xcb_change_property(demo->connection, XCB_PROP_MODE_REPLACE, demo->xcb_window, (*reply).atom, 4, 32, 1,
&(*demo->atom_wm_delete_window).atom);
free(reply);

Right now we are freeing only xcb_intern_atom_reply_t *reply, missing xcb_intern_atom_reply_t *net_wm_name_reply and xcb_intern_atom_reply_t *utf8_string_reply.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions