diff --git a/src/lj_alloc.c b/src/lj_alloc.c index 20e60493..cb704f7b 100644 --- a/src/lj_alloc.c +++ b/src/lj_alloc.c @@ -1057,7 +1057,7 @@ static size_t release_unused_segments(mstate m) mchunkptr p = align_as_chunk(base); size_t psize = chunksize(p); /* Can unmap if first chunk holds entire segment and not pinned */ - if (!cinuse(p) && (char *)p + psize >= base + size - TOP_FOOT_SIZE) { + if (!cinuse(p) && (char *)p + psize == (char *)mem2chunk(sp)) { tchunkptr tp = (tchunkptr)p; if (p == m->dv) { m->dv = 0;