]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Fix potential hang in UCLO redirection handling in hooks.
authorMike Pall <mike>
Wed, 10 Mar 2010 21:13:23 +0000 (22:13 +0100)
committerMike Pall <mike>
Wed, 10 Mar 2010 21:13:23 +0000 (22:13 +0100)
src/lj_dispatch.c

index f956aa1bc3a83be6e47aa1560b2eb4ef59a94258..30137ab27a1220226b50ff3427c2c3c63a2bb666 100644 (file)
@@ -333,15 +333,13 @@ static void callhook(lua_State *L, int event, BCLine line)
 static BCReg cur_topslot(GCproto *pt, const BCIns *pc, uint32_t nres)
 {
   BCIns ins = pc[-1];
-  for (;;) {
-    switch (bc_op(ins)) {
-    case BC_UCLO: ins = pc[bc_j(ins)]; break;
-    case BC_CALLM:
-    case BC_CALLMT: return bc_a(ins) + bc_c(ins) + nres-1+1;
-    case BC_RETM: return bc_a(ins) + bc_d(ins) + nres-1;
-    case BC_TSETM: return bc_a(ins) + nres-1;
-    default: return pt->framesize;
-    }
+  if (bc_op(ins) == BC_UCLO)
+    ins = pc[bc_j(ins)];
+  switch (bc_op(ins)) {
+  case BC_CALLM: case BC_CALLMT: return bc_a(ins) + bc_c(ins) + nres-1+1;
+  case BC_RETM: return bc_a(ins) + bc_d(ins) + nres-1;
+  case BC_TSETM: return bc_a(ins) + nres-1;
+  default: return pt->framesize;
   }
 }