浏览代码

Correct fix for stack check when recording BC_VARG.

Reported by Yichun Zhang.
Mike Pall 2 年之前
父节点
当前提交
b2791179ef
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/lj_record.c

+ 2 - 2
src/lj_record.c

@@ -1522,6 +1522,8 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
     } else if (dst + nresults > J->maxslot) {
     } else if (dst + nresults > J->maxslot) {
       J->maxslot = dst + (BCReg)nresults;
       J->maxslot = dst + (BCReg)nresults;
     }
     }
+    if (J->baseslot + J->maxslot >= LJ_MAX_JSLOTS)
+      lj_trace_err(J, LJ_TRERR_STACKOV);
     for (i = 0; i < nresults; i++)
     for (i = 0; i < nresults; i++)
       J->base[dst+i] = i < nvararg ? getslot(J, i - nvararg - 1) : TREF_NIL;
       J->base[dst+i] = i < nvararg ? getslot(J, i - nvararg - 1) : TREF_NIL;
   } else {  /* Unknown number of varargs passed to trace. */
   } else {  /* Unknown number of varargs passed to trace. */
@@ -1602,8 +1604,6 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
       lj_trace_err_info(J, LJ_TRERR_NYIBC);
       lj_trace_err_info(J, LJ_TRERR_NYIBC);
     }
     }
   }
   }
-  if (J->baseslot + J->maxslot >= LJ_MAX_JSLOTS)
-    lj_trace_err(J, LJ_TRERR_STACKOV);
 }
 }
 
 
 /* -- Record allocations -------------------------------------------------- */
 /* -- Record allocations -------------------------------------------------- */