diff --git a/src/hlua.c b/src/hlua.c index abd096d03..285d25589 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -1869,7 +1869,10 @@ __LJMP static int hlua_socket_receive(struct lua_State *L) /* Set pattern. */ lua_pushinteger(L, wanted); - lua_replace(L, 2); + + /* Check if we would replace the top by itself. */ + if (lua_gettop(L) != 2) + lua_replace(L, 2); /* init bufffer, and fiil it wih prefix. */ luaL_buffinit(L, &socket->b);