From 63e56bc208b7094164a950b3cedf1b6bad6a2ef7 Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Wed, 21 Nov 2007 14:04:48 -0500 Subject: [PATCH] Prevet a GPF when calling get_status on a failed connection. --- lxcb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lxcb.c b/lxcb.c index b7d35d8..129f5ce 100644 --- a/lxcb.c +++ b/lxcb.c @@ -108,6 +108,8 @@ extern void push_Setup(lua_State *L, const xcb_setup_t *x); //Temporary until I static int GetSetup(lua_State *L) { xcb_connection_t *c; + const xcb_setup_t *setup; + c = ((xcb_connection_t **)luaL_checkudata(L, 1, MT_DISPLAY))[0]; lua_getfenv(L, 1); @@ -115,7 +117,11 @@ static int GetSetup(lua_State *L) if (lua_toboolean(L, -1)) luaL_error(L, "Error: already disconnected"); - push_Setup(L, xcb_get_setup(c)); + setup = xcb_get_setup(c); + if (!setup) + luaL_error(L, "Error: connection failed"); + + push_Setup(L, setup); return 1; } -- 2.11.4.GIT