Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

sclang: fix Array-*slide crash

fixes #645

Signed-off-by: Tim Blechmann <tim@klingt.org>
  • Loading branch information...
commit a4c33b95dbd3ad5e5c91687d29376e17353c5c64 1 parent d3a9698
@timblechmann timblechmann authored
Showing with 7 additions and 5 deletions.
  1. +7 −5 lang/LangPrimSource/PyrArrayPrimitives.cpp
View
12 lang/LangPrimSource/PyrArrayPrimitives.cpp
@@ -1973,7 +1973,7 @@ int prArraySlide(struct VMGlobals *g, int numArgsPushed)
{
PyrSlot *a, *b, *c, *slots;
PyrObject *obj1, *obj2;
- int h, i, j, k, n, m, numslots, numwin;
+ int h, i, j, k, numslots, numwin;
a = g->sp - 2;
b = g->sp - 1;
@@ -1983,15 +1983,17 @@ int prArraySlide(struct VMGlobals *g, int numArgsPushed)
obj1 = slotRawObject(a);
slots = obj1->slots;
- m = slotRawInt(b);
- n = slotRawInt(c);
+ int m = slotRawInt(b);
+ int n = slotRawInt(c);
+ if (n <= 0)
+ return errFailed;
+
numwin = (obj1->size + n - m) / n;
numslots = numwin * m;
obj2 = instantiateObject(g->gc, obj1->classptr, numslots, false, true);
for (i=h=k=0; i<numwin; ++i,h+=n) {
- for (j=h; j<m+h; ++j) {
+ for (j=h; j<m+h; ++j)
slotCopy(&obj2->slots[k++],&slots[j]);
- }
}
obj2->size = k;
SetRaw(a, obj2);
Please sign in to comment.
Something went wrong with that request. Please try again.