screen:swap(): Avoid segfault on almost-deleted screens

When a screen is in the process of being removed, it is still valid, but
no longer in the global list of screens (globalconf.screens). In this
time frame, trying to swap screens could cause a NULL pointer
dereference.

Fix this by throwing a Lua error in this case instead.

Fixes: https://github.com/awesomeWM/awesome/issues/2110
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-11-19 15:40:20 +01:00
parent 65b6d12b44
commit ea413969f3

View file

@ -1222,6 +1222,9 @@ luaA_screen_swap(lua_State *L)
if(ref_s && ref_swap)
break;
}
if(!ref_s || !ref_swap)
return luaL_error(L, "Invalid call to screen:swap()");
/* swap ! */
*ref_s = swap;
*ref_swap = s;