From e655b07ecb1862e8698afcb90b2d7bc301c6283c Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 15 Jan 2019 23:57:45 -0500 Subject: [PATCH] adds assertions to protect u3r_mug against stack overflow --- noun/retrieve.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/noun/retrieve.c b/noun/retrieve.c index 485520a29..8f16a3aea 100644 --- a/noun/retrieve.c +++ b/noun/retrieve.c @@ -1603,6 +1603,17 @@ static inline mugframe* _mug_push(c3_ys mov, c3_ys off, u3_noun veb) { u3R->cap_p += mov; + + // ensure we haven't overflowed the stack + // (off==0 means we're on a north road) + // + if ( 0 == off ) { + c3_assert(u3R->cap_p > u3R->hat_p); + } + else { + c3_assert(u3R->cap_p < u3R->hat_p); + } + mugframe* cur = u3to(mugframe, u3R->cap_p + off); cur->veb = veb; cur->a = 0;