From be80aec475e95c31225375c42a6f1e0808056a1c Mon Sep 17 00:00:00 2001
From: Kaz Kylheku <kaz@kylheku.com>
Date: Mon, 26 Jun 2017 06:28:15 -0700
Subject: ffi: bugfix: varray alloc not accounting for null term.

* ffi.c (ffi_varray_alloc): Add tft->null_term to length.
---
 ffi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ffi.c b/ffi.c
index f9a4ebc3..049c16d1 100644
--- a/ffi.c
+++ b/ffi.c
@@ -381,7 +381,7 @@ static mem_t *ffi_fixed_alloc(struct txr_ffi_type *tft, val obj, val self)
 
 static mem_t *ffi_varray_alloc(struct txr_ffi_type *tft, val obj, val self)
 {
-  cnum len = c_num(length(obj));
+  cnum len = c_num(length(obj)) + tft->null_term;
   val eltype = tft->eltype;
   struct txr_ffi_type *etft = ffi_type_struct(eltype);
   return chk_calloc(len, etft->size);
-- 
cgit v1.2.3