~ chicken-core (chicken-5) f2adf1088311b0a020b8c61535c1605175aa8668


commit f2adf1088311b0a020b8c61535c1605175aa8668
Author:     Peter Bex <peter@more-magic.net>
AuthorDate: Fri Jul 7 11:07:43 2023 +0200
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Fri Jul 7 13:16:37 2023 +0200

    Skip weak locatives that were already invalidated
    
    This avoids a NULL pointer dereference
    
    Signed-off-by: felix <felix@call-with-current-continuation.org>

diff --git a/runtime.c b/runtime.c
index edda5377..fbce94fd 100644
--- a/runtime.c
+++ b/runtime.c
@@ -4126,6 +4126,7 @@ static C_regparm void C_fcall update_locatives(int mode)
            (mode == GC_REALLOC && !C_in_stackp(loc) && !C_in_heapp(loc))); /* NB: *old* heap! */
 
     ptr = C_block_item(loc, 0); /* fix up ptr */
+    if (ptr == 0) continue; /* Skip already dropped weak locatives */
     offset = C_unfix(C_block_item(loc, 1));
     obj = ptr - offset;
 
Trap