From ea413969f3444525d1c29773a57c7fa5335f1a9a Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 19 Nov 2017 15:40:20 +0100 Subject: [PATCH] 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 --- objects/screen.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/objects/screen.c b/objects/screen.c index 5b701f29..f0943c78 100644 --- a/objects/screen.c +++ b/objects/screen.c @@ -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;