shithub: sl

Download patch

ref: 309a7695296be56edae85fb025d7932d3af5c351
parent: dc951aa077334fa07bf3b322164981928d72473a
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Feb 1 15:44:53 EST 2025

read builtin: fix for cases where GC is called while reading

--- a/src/iostream.c
+++ b/src/iostream.c
@@ -116,9 +116,10 @@
 	if(nargs > 1)
 		argcount(nargs, 1);
 	value_t a = nargs == 0 ? symbol_value(FL_instrsym) : args[0];
-	ios_t *s = toiostream(a);
+	fl_gc_handle(&a);
 	value_t v = fl_read_sexpr(a);
-	return ios_eof(s) ? FL_eof : v;
+	fl_free_gc_handles(1);
+	return ios_eof(toiostream(a)) ? FL_eof : v;
 }
 
 BUILTIN("io-getc", io_getc)