diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-16 17:40:58 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-16 17:40:58 -0300 |
commit | c196348717dfda116726145220e5d1311547980e (patch) | |
tree | 83149c29559b888eed7a28e5f1558a67a912cf90 /lcode.c | |
parent | 669129a6d8210e758ba94ea2786a370946572f7d (diff) | |
download | lua-c196348717dfda116726145220e5d1311547980e.tar.gz lua-c196348717dfda116726145220e5d1311547980e.tar.bz2 lua-c196348717dfda116726145220e5d1311547980e.zip |
in case of memory allocation errors, sizecode and sizelineinfo can
be different
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 1.110 2002/08/20 20:03:05 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.111 2002/08/21 18:56:33 roberto Exp roberto $ |
3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -686,14 +686,14 @@ void luaK_fixline (FuncState *fs, int line) { | |||
686 | 686 | ||
687 | int luaK_code (FuncState *fs, Instruction i, int line) { | 687 | int luaK_code (FuncState *fs, Instruction i, int line) { |
688 | Proto *f = fs->f; | 688 | Proto *f = fs->f; |
689 | int oldsize = f->sizecode; | ||
690 | luaK_dischargejpc(fs); /* `pc' will change */ | 689 | luaK_dischargejpc(fs); /* `pc' will change */ |
691 | /* put new instruction in code array */ | 690 | /* put new instruction in code array */ |
692 | luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, | 691 | luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, |
693 | MAX_INT, "code size overflow"); | 692 | MAX_INT, "code size overflow"); |
694 | f->code[fs->pc] = i; | 693 | f->code[fs->pc] = i; |
695 | if (f->sizecode != oldsize) | 694 | /* save corresponding line information */ |
696 | luaM_reallocvector(fs->L, f->lineinfo, oldsize, f->sizecode, int); | 695 | luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, |
696 | MAX_INT, "code size overflow"); | ||
697 | f->lineinfo[fs->pc] = line; | 697 | f->lineinfo[fs->pc] = line; |
698 | return fs->pc++; | 698 | return fs->pc++; |
699 | } | 699 | } |