Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix index out of range SC bug.
  • Loading branch information
jnthn committed Feb 27, 2013
1 parent d1de3ee commit e58be0c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -2347,7 +2347,11 @@ public static SixModelObject createsc(String handle, ThreadContext tc) {
}
public static SixModelObject scsetobj(SixModelObject scRef, long idx, SixModelObject obj) {
if (scRef instanceof SCRefInstance) {
((SCRefInstance)scRef).referencedSC.root_objects.set((int)idx, obj);
ArrayList<SixModelObject> roots = ((SCRefInstance)scRef).referencedSC.root_objects;
if (roots.size() == idx)
roots.add(obj);
else
roots.set((int)idx, obj);
return obj;
}
else {
Expand All @@ -2357,7 +2361,11 @@ public static SixModelObject scsetobj(SixModelObject scRef, long idx, SixModelOb
public static SixModelObject scsetcode(SixModelObject scRef, long idx, SixModelObject obj) {
if (scRef instanceof SCRefInstance) {
if (obj instanceof CodeRef) {
((SCRefInstance)scRef).referencedSC.root_codes.set((int)idx, (CodeRef)obj);
ArrayList<CodeRef> roots = ((SCRefInstance)scRef).referencedSC.root_codes;
if (roots.size() == idx)
roots.add((CodeRef)obj);
else
roots.set((int)idx, (CodeRef)obj);
return obj;
}
else {
Expand Down

0 comments on commit e58be0c

Please sign in to comment.