Browse Source

Fix argument checks for coroutine.create().

Mike Pall 13 years ago
parent
commit
97b7edb206
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/lib_base.c

+ 2 - 1
src/lib_base.c

@@ -550,9 +550,10 @@ LJLIB_CF(coroutine_running)
 
 
 LJLIB_CF(coroutine_create)
 LJLIB_CF(coroutine_create)
 {
 {
-  lua_State *L1 = lua_newthread(L);
+  lua_State *L1;
   if (!(L->base < L->top && tvisfunc(L->base)))
   if (!(L->base < L->top && tvisfunc(L->base)))
     lj_err_argt(L, 1, LUA_TFUNCTION);
     lj_err_argt(L, 1, LUA_TFUNCTION);
+  L1 = lua_newthread(L);
   setfuncV(L, L1->top++, funcV(L->base));
   setfuncV(L, L1->top++, funcV(L->base));
   return 1;
   return 1;
 }
 }