mirror of
https://github.com/swaywm/sway.git
synced 2024-11-11 21:14:10 +01:00
Fix use after free in transactions
In set_instructions_ready, calling set_instruction_ready may cause any number of transactions to get applied, which removes them from the list being iterated. The iteration variables need to be adjusted accordingly.
This commit is contained in:
parent
7ad9d743fa
commit
073ac425d5
@ -364,7 +364,13 @@ static void set_instructions_ready(struct sway_view *view, int index) {
|
||||
struct sway_transaction_instruction *instruction =
|
||||
view->swayc->instructions->items[i];
|
||||
if (!instruction->ready) {
|
||||
// set_instruction_ready can remove instructions from the list we're
|
||||
// iterating
|
||||
size_t length = view->swayc->instructions->length;
|
||||
set_instruction_ready(instruction);
|
||||
size_t num_removed = length - view->swayc->instructions->length;
|
||||
i -= num_removed;
|
||||
index -= num_removed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user