diff options
| author | Haitao Li <lihaitao@gmail.com> | 2011-12-05 00:33:25 +0800 |
|---|---|---|
| committer | Haitao Li <lihaitao@gmail.com> | 2011-12-05 00:38:38 +0800 |
| commit | 96b0881a685e4960439f56cc5ffdcff112894d3d (patch) | |
| tree | 46e2dec728bd3481ddea34276a842fd0aa8aa251 /src/comp/middle | |
| parent | 9711596bec1fbc40a09c7c23ef12fe06a8d9bd3d (diff) | |
| download | rust-96b0881a685e4960439f56cc5ffdcff112894d3d.tar.gz rust-96b0881a685e4960439f56cc5ffdcff112894d3d.zip | |
rustc: Fix memory leak in do-while loop
Issue #1257
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/trans.rs | 7 |
1 files changed, 5 insertions, 2 deletions
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; } |
