diff --git a/src/hlua.c b/src/hlua.c index 39b64dc38..fbed29946 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -3148,6 +3148,11 @@ __LJMP static int hlua_socket_connect(struct lua_State *L) struct stconn *sc; struct stream *s; + /* Get hlua struct, or NULL if we execute from main lua state */ + hlua = hlua_gethlua(L); + if (!hlua) + return 0; + if (lua_gettop(L) < 2) WILL_LJMP(luaL_error(L, "connect: need at least 2 arguments")); @@ -3222,11 +3227,6 @@ __LJMP static int hlua_socket_connect(struct lua_State *L) WILL_LJMP(luaL_error(L, "connect: internal error")); } - /* Get hlua struct, or NULL if we execute from main lua state */ - hlua = hlua_gethlua(L); - if (!hlua) - return 0; - /* inform the stream that we want to be notified whenever the * connection completes. */