diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-07 16:59:52 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-07 16:59:52 -0200 |
commit | 76223730332cbda5d47c09f019ce721b91bd5be2 (patch) | |
tree | 375c159891df5faf827dde4175ce42b7aa503194 /lundump.c | |
parent | 46bc7f2bf7cf7f48c354fde6b9571b795bdd5b4d (diff) | |
download | lua-github-76223730332cbda5d47c09f019ce721b91bd5be2.tar.gz |
using explicit tests for allocation overflow whenever possible
Diffstat (limited to 'lundump.c')
-rw-r--r-- | lundump.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 2.47 2017/06/29 15:06:44 roberto Exp roberto $ +** $Id: lundump.c,v 2.48 2017/11/28 11:19:07 roberto Exp roberto $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -114,7 +114,7 @@ static TString *LoadString (LoadState *S) { static void LoadCode (LoadState *S, Proto *f) { int n = LoadInt(S); - f->code = luaM_newvector(S->L, n, Instruction); + f->code = luaM_newvectorchecked(S->L, n, Instruction); f->sizecode = n; LoadVector(S, f->code, n); } @@ -126,7 +126,7 @@ static void LoadFunction(LoadState *S, Proto *f, TString *psource); static void LoadConstants (LoadState *S, Proto *f) { int i; int n = LoadInt(S); - f->k = luaM_newvector(S->L, n, TValue); + f->k = luaM_newvectorchecked(S->L, n, TValue); f->sizek = n; for (i = 0; i < n; i++) setnilvalue(&f->k[i]); @@ -159,7 +159,7 @@ static void LoadConstants (LoadState *S, Proto *f) { static void LoadProtos (LoadState *S, Proto *f) { int i; int n = LoadInt(S); - f->p = luaM_newvector(S->L, n, Proto *); + f->p = luaM_newvectorchecked(S->L, n, Proto *); f->sizep = n; for (i = 0; i < n; i++) f->p[i] = NULL; @@ -173,7 +173,7 @@ static void LoadProtos (LoadState *S, Proto *f) { static void LoadUpvalues (LoadState *S, Proto *f) { int i, n; n = LoadInt(S); - f->upvalues = luaM_newvector(S->L, n, Upvaldesc); + f->upvalues = luaM_newvectorchecked(S->L, n, Upvaldesc); f->sizeupvalues = n; for (i = 0; i < n; i++) f->upvalues[i].name = NULL; @@ -187,18 +187,18 @@ static void LoadUpvalues (LoadState *S, Proto *f) { static void LoadDebug (LoadState *S, Proto *f) { int i, n; n = LoadInt(S); - f->lineinfo = luaM_newvector(S->L, n, ls_byte); + f->lineinfo = luaM_newvectorchecked(S->L, n, ls_byte); f->sizelineinfo = n; LoadVector(S, f->lineinfo, n); n = LoadInt(S); - f->abslineinfo = luaM_newvector(S->L, n, AbsLineInfo); + f->abslineinfo = luaM_newvectorchecked(S->L, n, AbsLineInfo); f->sizeabslineinfo = n; for (i = 0; i < n; i++) { f->abslineinfo[i].pc = LoadInt(S); f->abslineinfo[i].line = LoadInt(S); } n = LoadInt(S); - f->locvars = luaM_newvector(S->L, n, LocVar); + f->locvars = luaM_newvectorchecked(S->L, n, LocVar); f->sizelocvars = n; for (i = 0; i < n; i++) f->locvars[i].varname = NULL; |