commit 92a4bc646a52b1715f4885d7459c07b7a26a2d21 parent 7ad9d743faa485b35ee5d38224736f445db071d2 Author: Brian Ashworth <RedSoxFan@users.noreply.github.com> Date: Sat, 28 Jul 2018 01:31:43 -0400 Merge pull request #2370 from RyanDwyer/transactions-use-after-free Fix use after free in transactions Diffstat:
| M | sway/desktop/transaction.c | | | 6 | ++++++ |
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c @@ -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; } } }