~ chicken-core (chicken-5) 24df3271dfae12532dcd74a9a5428f2140587a2d


commit 24df3271dfae12532dcd74a9a5428f2140587a2d
Author:     Peter Bex <peter.bex@xs4all.nl>
AuthorDate: Thu Jun 21 20:43:43 2012 +0200
Commit:     Christian Kellermann <ckeen@pestilenz.org>
CommitDate: Fri Jun 22 12:11:43 2012 +0200

    Fix out-of-memory check so it includes alignment (and prevent future bugs by removing the code duplication)
    
    Signed-off-by: Christian Kellermann <ckeen@pestilenz.org>

diff --git a/runtime.c b/runtime.c
index bf4e578a..b0ccc85a 100644
--- a/runtime.c
+++ b/runtime.c
@@ -3346,11 +3346,11 @@ C_regparm void C_fcall really_remark(C_word *x)
   n = C_header_size(p);
   bytes = (h & C_BYTEBLOCK_BIT) ? n : n * sizeof(C_word);
 
-  if(((C_byte *)p2 + bytes + sizeof(C_word)) > new_tospace_limit) {
+  new_tospace_top = ((C_byte *)p2 + C_align(bytes) + sizeof(C_word));
+  if(new_tospace_top > new_tospace_limit) {
     panic(C_text("out of memory - heap full while resizing"));
   }
 
-  new_tospace_top = (C_byte *)p2 + C_align(bytes) + sizeof(C_word);
   *x = (C_word)p2;
   p2->header = h;
   assert(!is_fptr(h));
Trap