]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
FFI: Fix pragma push stack limit check and throw on overflow.
authorMike Pall <mike>
Tue, 7 Nov 2023 21:25:42 +0000 (22:25 +0100)
committerMike Pall <mike>
Tue, 7 Nov 2023 21:25:42 +0000 (22:25 +0100)
Reported by Sergey Kaplun. #1114

src/lj_cparse.c

index f807c5aed1bb48a3135c79aad2d1f02075bf5a30..2ef7dbe1fe0778bba29b827fbddfdad1dd0af554 100644 (file)
@@ -1747,9 +1747,11 @@ static void cp_pragma(CPState *cp, BCLine pragmaline)
     cp_check(cp, '(');
     if (cp->tok == CTOK_IDENT) {
       if (cp->str->hash == H_(738e923c,a1b65954)) {  /* push */
-       if (cp->curpack < CPARSE_MAX_PACKSTACK) {
+       if (cp->curpack < CPARSE_MAX_PACKSTACK-1) {
          cp->packstack[cp->curpack+1] = cp->packstack[cp->curpack];
          cp->curpack++;
+       } else {
+         cp_errmsg(cp, cp->tok, LJ_ERR_XLEVELS);
        }
       } else if (cp->str->hash == H_(6c71cf27,6c71cf27)) {  /* pop */
        if (cp->curpack > 0) cp->curpack--;