From 08e4c304cd33d33892a0435c9ee4a865fc915e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Lepage=20Vall=C3=A9e?= Date: Tue, 30 Aug 2016 06:59:45 -0400 Subject: [PATCH] client: Fix a potential crash due to a race condition. (#1055) If raise was called from the awful.rule `manage` callback at startup with a client already present it crashed due to a buffer underflow. --- objects/client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/objects/client.c b/objects/client.c index ce81e9add..838112d18 100644 --- a/objects/client.c +++ b/objects/client.c @@ -2383,7 +2383,10 @@ luaA_client_raise(lua_State *L) client_t *c = luaA_checkudata(L, 1, &client_class); /* Avoid sending the signal if nothing was done */ - if (c->transient_for == NULL && globalconf.stack.tab[globalconf.stack.len-1] == c) + if (c->transient_for == NULL && + globalconf.stack.len && + globalconf.stack.tab[globalconf.stack.len-1] == c + ) return 0; client_raise(c);