From 2d8421730bb05179b40ce72796f8b27f407ba9d3 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 6 Mar 2016 10:43:23 +0100 Subject: [PATCH] Fix stack handling on errors for the mouse grabber This one actually uses the return value from the function (where's the consistency?!), so the code is fixed to only pop the return value if there is actually one. Signed-off-by: Uli Schlachter --- event.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/event.c b/event.c index fc9f478a..555978bf 100644 --- a/event.c +++ b/event.c @@ -122,10 +122,11 @@ event_handle_mousegrabber(int x, int y, uint16_t mask) { warn("Stopping mousegrabber."); luaA_mousegrabber_stop(L); + } else { + if(!lua_isboolean(L, -1) || !lua_toboolean(L, -1)) + luaA_mousegrabber_stop(L); + lua_pop(L, 1); /* pop returned value */ } - else if(!lua_isboolean(L, -1) || !lua_toboolean(L, -1)) - luaA_mousegrabber_stop(L); - lua_pop(L, 1); /* pop returned value */ return true; } return false;