diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-08-20 15:15:23 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-08-20 15:15:23 -0300 |
commit | 75620b45ae9d500a3251a0e698de98ab588d2a29 (patch) | |
tree | 1b04673fe967d3849928f3bb4d39a7e9c6155bf6 /lparser.c | |
parent | 3e88b72b8e71c0946d089a04876e7bdc61d187a9 (diff) | |
download | lua-75620b45ae9d500a3251a0e698de98ab588d2a29.tar.gz lua-75620b45ae9d500a3251a0e698de98ab588d2a29.tar.bz2 lua-75620b45ae9d500a3251a0e698de98ab588d2a29.zip |
'lcode.c' can use 'checklimit', too
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -84,8 +84,8 @@ static l_noret errorlimit (FuncState *fs, int limit, const char *what) { | |||
84 | } | 84 | } |
85 | 85 | ||
86 | 86 | ||
87 | static void checklimit (FuncState *fs, int v, int l, const char *what) { | 87 | void luaY_checklimit (FuncState *fs, int v, int l, const char *what) { |
88 | if (v > l) errorlimit(fs, l, what); | 88 | if (l_unlikely(v > l)) errorlimit(fs, l, what); |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
@@ -196,7 +196,7 @@ static int new_localvarkind (LexState *ls, TString *name, lu_byte kind) { | |||
196 | FuncState *fs = ls->fs; | 196 | FuncState *fs = ls->fs; |
197 | Dyndata *dyd = ls->dyd; | 197 | Dyndata *dyd = ls->dyd; |
198 | Vardesc *var; | 198 | Vardesc *var; |
199 | checklimit(fs, dyd->actvar.n + 1 - fs->firstlocal, | 199 | luaY_checklimit(fs, dyd->actvar.n + 1 - fs->firstlocal, |
200 | MAXVARS, "local variables"); | 200 | MAXVARS, "local variables"); |
201 | luaM_growvector(L, dyd->actvar.arr, dyd->actvar.n + 1, | 201 | luaM_growvector(L, dyd->actvar.arr, dyd->actvar.n + 1, |
202 | dyd->actvar.size, Vardesc, USHRT_MAX, "local variables"); | 202 | dyd->actvar.size, Vardesc, USHRT_MAX, "local variables"); |
@@ -361,7 +361,7 @@ static int searchupvalue (FuncState *fs, TString *name) { | |||
361 | static Upvaldesc *allocupvalue (FuncState *fs) { | 361 | static Upvaldesc *allocupvalue (FuncState *fs) { |
362 | Proto *f = fs->f; | 362 | Proto *f = fs->f; |
363 | int oldsize = f->sizeupvalues; | 363 | int oldsize = f->sizeupvalues; |
364 | checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues"); | 364 | luaY_checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues"); |
365 | luaM_growvector(fs->ls->L, f->upvalues, fs->nups, f->sizeupvalues, | 365 | luaM_growvector(fs->ls->L, f->upvalues, fs->nups, f->sizeupvalues, |
366 | Upvaldesc, MAXUPVAL, "upvalues"); | 366 | Upvaldesc, MAXUPVAL, "upvalues"); |
367 | while (oldsize < f->sizeupvalues) | 367 | while (oldsize < f->sizeupvalues) |
@@ -860,7 +860,7 @@ static void recfield (LexState *ls, ConsControl *cc) { | |||
860 | lu_byte reg = ls->fs->freereg; | 860 | lu_byte reg = ls->fs->freereg; |
861 | expdesc tab, key, val; | 861 | expdesc tab, key, val; |
862 | if (ls->t.token == TK_NAME) { | 862 | if (ls->t.token == TK_NAME) { |
863 | checklimit(fs, cc->nh, INT_MAX, "items in a constructor"); | 863 | luaY_checklimit(fs, cc->nh, INT_MAX / 2, "items in a constructor"); |
864 | codename(ls, &key); | 864 | codename(ls, &key); |
865 | } | 865 | } |
866 | else /* ls->t.token == '[' */ | 866 | else /* ls->t.token == '[' */ |