From: Ingo Bürk Date: Sun, 25 Oct 2015 13:27:08 +0000 (+0100) Subject: Mark assignment as run before executing it. X-Git-Tag: 4.12~121^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=refs%2Fpull%2F2037%2Fhead;p=i3%2Fi3 Mark assignment as run before executing it. We need to store the information that an assignment was run for a window before actually executing the command. Otherwise, if the command causes a change that causes assignments to be run again, the window might be matched again, causing an infinite loop and hence i3 to freeze or crash. --- diff --git a/src/assignments.c b/src/assignments.c index 9de50e12..6c563357 100644 --- a/src/assignments.c +++ b/src/assignments.c @@ -40,6 +40,13 @@ void run_assignments(i3Window *window) { if (skip) continue; + /* Store that we ran this assignment to not execute it again. We have + * to do this before running the actual command to prevent infinite + * loops. */ + window->nr_assignments++; + window->ran_assignments = srealloc(window->ran_assignments, sizeof(Assignment *) * window->nr_assignments); + window->ran_assignments[window->nr_assignments - 1] = current; + DLOG("matching assignment, would do:\n"); if (current->type == A_COMMAND) { DLOG("execute command %s\n", current->dest.command); @@ -53,11 +60,6 @@ void run_assignments(i3Window *window) { command_result_free(result); } - - /* Store that we ran this assignment to not execute it again */ - window->nr_assignments++; - window->ran_assignments = srealloc(window->ran_assignments, sizeof(Assignment *) * window->nr_assignments); - window->ran_assignments[window->nr_assignments - 1] = current; } /* If any of the commands required re-rendering, we will do that now. */