Changeset 98735eb in mainline for uspace/srv/hid/display/client.c


Ignore:
Timestamp:
2021-06-10T13:22:33Z (3 years ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
90f1f19
Parents:
d7f82635
git-author:
Jiri Svoboda <jiri@…> (2021-06-08 17:55:50)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-06-10 13:22:33)
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

    rd7f82635 r98735eb  
    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.