summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-01-01 22:10:04 -0800
committerKaz Kylheku <kaz@kylheku.com>2024-01-01 22:10:04 -0800
commit8f301e63a60fb76b11ca86e23853a3ead6dbf144 (patch)
treed9ceb05df3159e1a79d282eaa3d28b119b0f821b
parentd28977171f795ced690cbbc3ab9bb4f34e02f956 (diff)
downloadtxr-8f301e63a60fb76b11ca86e23853a3ead6dbf144.tar.gz
txr-8f301e63a60fb76b11ca86e23853a3ead6dbf144.tar.bz2
txr-8f301e63a60fb76b11ca86e23853a3ead6dbf144.zip
iter_begin: gc problem.
Also affects seq_begin. * lib.c (seq_begin, iter_begin): We must gc_protect the incoming obj also, not only the iter. Both these pointers are in the seq_info_t structure which is no longer used at the time the iterator is being allocated by the call to cobj, and so may be prematurely garbage collected.
-rw-r--r--lib.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 0e374c70..b1ce9e9c 100644
--- a/lib.c
+++ b/lib.c
@@ -1195,6 +1195,7 @@ val seq_begin(val obj)
iter = si->ui.iter;
si_obj = cobj(coerce(mem_t *, si), seq_iter_cls, &seq_iter_ops);
gc_hint(iter);
+ gc_hint(obj);
return si_obj;
}
@@ -1250,6 +1251,7 @@ val iter_begin(val obj)
iter = si->ui.iter;
si_obj = cobj(coerce(mem_t *, si), seq_iter_cls, &seq_iter_ops);
gc_hint(iter);
+ gc_hint(obj);
return si_obj;
}
}