From c8cea26d617aa2c4fe1dc5ea2372c74bd601a0a5 Mon Sep 17 00:00:00 2001 From: Doug Currie Date: Wed, 9 Aug 2017 21:59:04 +0100 Subject: [PATCH] Fix dropped GC root in fl_vector_alloc (#48) --- builtins.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/builtins.c b/builtins.c index 504450f..3cad822 100644 --- a/builtins.c +++ b/builtins.c @@ -284,16 +284,14 @@ static value_t fl_vector_alloc(value_t *args, u_int32_t nargs) i = (fixnum_t)toulong(args[0], "vector.alloc"); if (i < 0) lerror(ArgError, "vector.alloc: invalid size"); + v = alloc_vector((unsigned)i, 0); if (nargs == 2) f = args[1]; else f = FL_UNSPECIFIED; - v = alloc_vector((unsigned)i, f==FL_UNSPECIFIED); - if (f != FL_UNSPECIFIED) { - int k; - for(k=0; k < i; k++) - vector_elt(v,k) = f; - } + int k; + for(k=0; k < i; k++) + vector_elt(v,k) = f; return v; }