shithub: femtolisp

Download patch

ref: 19cecdac20157dc8638033e0d59f49ddcd1d82ff
parent: 2afeb42f926b3246728306bd8050d1c459122609
author: Doug Currie <github.9.eeeeeee@spamgourmet.com>
date: Wed Aug 9 17:59:04 EDT 2017

Fix dropped GC root in fl_vector_alloc (#48)


--- a/builtins.c
+++ b/builtins.c
@@ -284,16 +284,14 @@
     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;
 }