summaryrefslogtreecommitdiff
path: root/6/simp.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-01-24 01:55:39 -0800
committerOri Bernstein <ori@eigenstate.org>2016-01-24 01:55:39 -0800
commit89182b0cf8f7adf2f8a4708d750452d9a226aeea (patch)
treec826da0d3b7255df26ca41e79e733914f9449eb1 /6/simp.c
parentfd84fa03901b4b8a72a54552f302755d6c84aeba (diff)
downloadmc-89182b0cf8f7adf2f8a4708d750452d9a226aeea.tar.gz
Fix crash with lengthless arrays.
It's not just pointers that have no upper bound.
Diffstat (limited to '6/simp.c')
-rw-r--r--6/simp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/6/simp.c b/6/simp.c
index dbd96b8..08f6e27 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -948,7 +948,7 @@ static Node *simpslice(Simp *s, Node *n, Node *dst)
{
Node *t;
Node *start, *end;
- Node *seq, *base, *sz, *len;
+ Node *seq, *base, *sz, *len, *max;
Node *stbase, *stlen;
if (dst)
@@ -965,11 +965,13 @@ static Node *simpslice(Simp *s, Node *n, Node *dst)
len = sub(end, start);
/* we can be storing through a pointer, in the case
* of '*foo = bar'. */
+ max = seqlen(s, seq, tyword);
+ if (max)
+ checkidx(s, Ole, max, end);
if (tybase(exprtype(t))->type == Typtr) {
stbase = set(simpcast(s, t, mktyptr(t->loc, tyintptr)), base);
sz = addk(simpcast(s, t, mktyptr(t->loc, tyintptr)), Ptrsz);
} else {
- checkidx(s, Ole, seqlen(s, seq, tyword), end);
stbase = set(deref(addr(s, t, tyintptr), NULL), base);
sz = addk(addr(s, t, tyintptr), Ptrsz);
}