From 8de35a45143c48d80b522441558f1a1b2fdaa174 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 3 Jul 2012 19:17:23 +0200 Subject: [PATCH] vbscript: Fixed 'exit do' statements crossing for in loops. --- dlls/vbscript/compile.c | 9 ++++++--- dlls/vbscript/interp.c | 6 ++++-- dlls/vbscript/tests/lang.vbs | 6 ++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index e93b2577a77..68e0a707df4 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -682,7 +682,7 @@ static HRESULT compile_foreach_statement(compile_ctx_t *ctx, foreach_statement_t static HRESULT compile_forto_statement(compile_ctx_t *ctx, forto_statement_t *stat) { - statement_ctx_t loop_ctx = {0}; + statement_ctx_t loop_ctx = {2}; unsigned step_instr, instr; BSTR identifier; HRESULT hres; @@ -743,9 +743,12 @@ static HRESULT compile_forto_statement(compile_ctx_t *ctx, forto_statement_t *st if(FAILED(hres)) return hres; - label_set_addr(ctx, loop_ctx.for_end_label); + hres = push_instr_uint(ctx, OP_pop, 2); + if(FAILED(hres)) + return hres; - return push_instr_uint(ctx, OP_pop, 2); + label_set_addr(ctx, loop_ctx.for_end_label); + return S_OK; } static HRESULT compile_assignment(compile_ctx_t *ctx, member_expression_t *member_expr, expression_t *value_expr, BOOL is_set) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 9a8f97e1394..3a6fb387237 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -894,10 +894,12 @@ static HRESULT interp_step(exec_ctx_t *ctx) if(FAILED(hres)) return hres; - if(hres == VARCMP_EQ || hres == (gteq_zero ? VARCMP_LT : VARCMP_GT)) + if(hres == VARCMP_EQ || hres == (gteq_zero ? VARCMP_LT : VARCMP_GT)) { ctx->instr++; - else + }else { + stack_popn(ctx, 2); instr_jmp(ctx, ctx->instr->arg1.uint); + } return S_OK; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 1636de18443..f203e8332d5 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -415,6 +415,12 @@ for x = 1 to 100 Call ok(false, "exit for not escaped the loop?") next +do while true + for x = 1 to 100 + exit do + next +loop + Call collectionObj.reset() y = 0 x = 10 -- 2.11.4.GIT