The code to replace $wid/$pid died on $foo.

It failed to increment a variable after finding a $ but no pid or wid,
which led to a fun infinite loop. Also don't check if c[1] is w if we
already established it was p.
This commit is contained in:
Mikael Magnusson 2008-06-07 05:12:04 +02:00
parent d81d54c7a9
commit 8f37a97a4c

View file

@ -144,7 +144,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
if (data->client) { if (data->client) {
gchar *c, *before, *expand; gchar *c, *before, *expand;
/* replace occurances of $pid and $wid */ /* replace occurrences of $pid and $wid */
expand = NULL; expand = NULL;
before = cmd; before = cmd;
@ -168,8 +168,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
before = c + 4; /* 4 = strlen("$pid") */ before = c + 4; /* 4 = strlen("$pid") */
} }
else if ((c[1] == 'w' || c[1] == 'W') &&
if ((c[1] == 'w' || c[1] == 'W') &&
(c[2] == 'i' || c[2] == 'I') && (c[2] == 'i' || c[2] == 'I') &&
(c[3] == 'd' || c[3] == 'D') && (c[3] == 'd' || c[3] == 'D') &&
!g_ascii_isalnum(c[4])) !g_ascii_isalnum(c[4]))
@ -187,6 +186,8 @@ static gboolean run_func(ObActionsData *data, gpointer options)
before = c + 4; /* 4 = strlen("$wid") */ before = c + 4; /* 4 = strlen("$wid") */
} }
else
before = c + 1; /* no infinite loops plz */
} }
if (expand) { if (expand) {