From 5d2d296e20822f120142d5437fddc91c3449f5c5 Mon Sep 17 00:00:00 2001 From: Kevin Zander Date: Sun, 24 Jun 2018 14:34:20 -0500 Subject: [PATCH] Return nil when indexing screen by number --- objects/screen.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/objects/screen.c b/objects/screen.c index 200da4bb..7b0d0219 100644 --- a/objects/screen.c +++ b/objects/screen.c @@ -229,8 +229,11 @@ luaA_checkscreen(lua_State *L, int sidx) { int screen = lua_tointeger(L, sidx); if(screen < 1 || screen > globalconf.screens.len) - luaL_error(L, "invalid screen number: %d (of %d existing)", - screen, globalconf.screens.len); + { + luaA_warn(L, "invalid screen number: %d (of %d existing)", screen, globalconf.screens.len); + lua_pushnil(L); + return NULL; + } return globalconf.screens.tab[screen - 1]; } else return luaA_checkudata(L, sidx, &screen_class);