Changeset 4b72e81 in mainline for uspace/srv/hid/display/client.c


Ignore:
Timestamp:
2021-06-09T11:56:03Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Children:
1bebc906
Parents:
4055fe63
git-author:
Jiri Svoboda <jiri@…> (2021-06-08 17:55:50)
git-committer:
Jiri Svoboda <jiri@…> (2021-06-09 11:56:03)
Message:

Purge events from client event queue when destroying window

If the client had events queued for a particular window and that got
destroyed, later these events, pointing to freed (and reused) memory
would be handed to the client with the wrong window ID (which was
read from the wrong/recycled memory block).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/client.c

    r4055fe63 r4b72e81  
    119119        }
    120120
     121        /* Make sure no event in the queue is referencing the window */
     122        ds_client_purge_window_events(wnd->client, wnd);
     123
    121124        list_remove(&wnd->lcwindows);
    122125        wnd->client = NULL;
     
    199202}
    200203
     204/** Purge events from client event queue referring to a window.
     205 *
     206 * @param client Client
     207 * @param window Window
     208 */
     209void ds_client_purge_window_events(ds_client_t *client,
     210    ds_window_t *window)
     211{
     212        link_t *cur;
     213        link_t *next;
     214        ds_window_ev_t *wevent;
     215
     216        cur = list_first(&client->events);
     217        while (cur != NULL) {
     218                next = list_next(cur, &client->events);
     219                wevent = list_get_instance(cur, ds_window_ev_t, levents);
     220
     221                if (wevent->window == window)
     222                        list_remove(cur);
     223
     224                cur = next;
     225        }
     226}
     227
    201228/** Post close event to the client's message queue.
    202229 *
Note: See TracChangeset for help on using the changeset viewer.