Skip to content

Commit 0957525

Browse files
committed
Fix array out of bounds index in load_environment.
Closes #696.
1 parent 1a6419b commit 0957525

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/comp/middle/trans.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4655,11 +4655,11 @@ fn load_environment(&@block_ctxt cx, &@fn_ctxt fcx,
46554655
C_int(abi::closure_elt_bindings)]);
46564656
auto llremotebindingsptr =
46574657
copy_args_bcx.build.Load(llremotebindingsptrptr);
4658+
auto base = 0u;
46584659
auto i = 0u;
46594660
auto end = std::ivec::len(upvars);
46604661
if (!option::is_none(cx.fcx.lliterbody)) {
4661-
end += 1u;
4662-
i += 1u;
4662+
base += 1u;
46634663
auto lliterbodyptr =
46644664
copy_args_bcx.build.GEP(llremotebindingsptr,
46654665
~[C_int(0), C_int(0)]);
@@ -4670,7 +4670,7 @@ fn load_environment(&@block_ctxt cx, &@fn_ctxt fcx,
46704670
auto upvar_id = upvars.(i);
46714671
auto llupvarptrptr =
46724672
copy_args_bcx.build.GEP(llremotebindingsptr,
4673-
~[C_int(0), C_int(i as int)]);
4673+
~[C_int(0), C_int(base+i as int)]);
46744674
auto llupvarptr = copy_args_bcx.build.Load(llupvarptrptr);
46754675
fcx.llupvars.insert(upvar_id, llupvarptr);
46764676
i += 1u;

0 commit comments

Comments
 (0)