From 96b0881a685e4960439f56cc5ffdcff112894d3d Mon Sep 17 00:00:00 2001 From: Haitao Li Date: Mon, 5 Dec 2011 00:33:25 +0800 Subject: rustc: Fix memory leak in do-while loop Issue #1257 --- src/comp/middle/trans.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/comp') diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 6a70d9e109d..7d52316d9a8 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -2844,8 +2844,11 @@ fn trans_do_while(cx: @block_ctxt, body: ast::blk, cond: @ast::expr) -> new_loop_scope_block_ctxt(cx, option::none::<@block_ctxt>, next_cx, "do-while loop body"); let body_end = trans_block(body_cx, body); - let cond_res = trans_temp_expr(body_end, cond); - CondBr(cond_res.bcx, cond_res.val, body_cx.llbb, next_cx.llbb); + let cond_cx = new_scope_block_ctxt(body_cx, "do-while cond"); + Br(body_end, cond_cx.llbb); + let cond_res = trans_temp_expr(cond_cx, cond); + let cond_bcx = trans_block_cleanups(cond_res.bcx, cond_cx); + CondBr(cond_bcx, cond_res.val, body_cx.llbb, next_cx.llbb); Br(cx, body_cx.llbb); ret next_cx; } -- cgit 1.4.1-3-g733a5