diff options
-rw-r--r-- | bugs | 43 | ||||
-rw-r--r-- | ldebug.c | 10 |
2 files changed, 49 insertions, 4 deletions
@@ -1052,3 +1052,46 @@ patch = [[ | |||
1052 | ]], | 1052 | ]], |
1053 | 1053 | ||
1054 | } | 1054 | } |
1055 | |||
1056 | |||
1057 | Bug{ | ||
1058 | what = [[wrong message error in some cases involving closures]], | ||
1059 | |||
1060 | report = [[Shmuel Zeigerman, on 07/2006]], | ||
1061 | |||
1062 | since = "Lua 5.1", | ||
1063 | |||
1064 | example = [[ | ||
1065 | local Var | ||
1066 | local function main() | ||
1067 | NoSuchName (function() Var=0 end) | ||
1068 | end | ||
1069 | main() | ||
1070 | --> lua5.1: temp:3: attempt to call upvalue 'Var' (a nil value) | ||
1071 | ]], | ||
1072 | |||
1073 | patch = [[ | ||
1074 | *ldebug.c: | ||
1075 | @@ -435,14 +435,16 @@ | ||
1076 | break; | ||
1077 | } | ||
1078 | case OP_CLOSURE: { | ||
1079 | - int nup; | ||
1080 | + int nup, j; | ||
1081 | check(b < pt->sizep); | ||
1082 | nup = pt->p[b]->nups; | ||
1083 | check(pc + nup < pt->sizecode); | ||
1084 | - for (; nup>0; nup--) { | ||
1085 | - OpCode op1 = GET_OPCODE(pt->code[pc+nup]); | ||
1086 | + for (j = 1; j <= nup; j++) { | ||
1087 | + OpCode op1 = GET_OPCODE(pt->code[pc + j]); | ||
1088 | check(op1 == OP_GETUPVAL || op1 == OP_MOVE); | ||
1089 | } | ||
1090 | + if (reg != NO_REG) /* tracing? */ | ||
1091 | + pc += nup; /* do not 'execute' these pseudo-instructions */ | ||
1092 | break; | ||
1093 | } | ||
1094 | case OP_VARARG: { | ||
1095 | ]], | ||
1096 | |||
1097 | } | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 2.29 2005/12/22 16:19:56 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.30 2006/07/11 15:53:29 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -435,14 +435,16 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) { | |||
435 | break; | 435 | break; |
436 | } | 436 | } |
437 | case OP_CLOSURE: { | 437 | case OP_CLOSURE: { |
438 | int nup; | 438 | int nup, j; |
439 | check(b < pt->sizep); | 439 | check(b < pt->sizep); |
440 | nup = pt->p[b]->nups; | 440 | nup = pt->p[b]->nups; |
441 | check(pc + nup < pt->sizecode); | 441 | check(pc + nup < pt->sizecode); |
442 | for (; nup>0; nup--) { | 442 | for (j = 1; j <= nup; j++) { |
443 | OpCode op1 = GET_OPCODE(pt->code[pc+nup]); | 443 | OpCode op1 = GET_OPCODE(pt->code[pc + j]); |
444 | check(op1 == OP_GETUPVAL || op1 == OP_MOVE); | 444 | check(op1 == OP_GETUPVAL || op1 == OP_MOVE); |
445 | } | 445 | } |
446 | if (reg != NO_REG) /* tracing? */ | ||
447 | pc += nup; /* do not 'execute' these pseudo-instructions */ | ||
446 | break; | 448 | break; |
447 | } | 449 | } |
448 | case OP_VARARG: { | 450 | case OP_VARARG: { |