summaryrefslogtreecommitdiffstats
path: root/ffi.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-04-28 06:12:13 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-04-28 06:12:13 -0700
commit046fcbaca4d0abb62b572231a5f941514e92d35b (patch)
tree4e3e8b99da703044b3410844efda11a801f51c25 /ffi.c
parent6b7a88b83ff5f3574e05a7677c65a232d667d52c (diff)
downloadtxr-046fcbaca4d0abb62b572231a5f941514e92d35b.tar.gz
txr-046fcbaca4d0abb62b572231a5f941514e92d35b.tar.bz2
txr-046fcbaca4d0abb62b572231a5f941514e92d35b.zip
ffi: use chk_calloc for txr_ffi_type.
Let's defend against uninitialized struct member bugs over this type which has grown somewhat complicated. * ffi.c (make_ffi_type_struct): Use chk_calloc for tft. (make_ffi_type_array): Likewise, and remove a couple of explicit zero initializations.
Diffstat (limited to 'ffi.c')
-rw-r--r--ffi.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/ffi.c b/ffi.c
index 8af0e554..f4062eb7 100644
--- a/ffi.c
+++ b/ffi.c
@@ -890,7 +890,7 @@ static val make_ffi_type_struct(val syntax, val lisp_type,
val slots, val types)
{
struct txr_ffi_type *tft = coerce(struct txr_ffi_type *,
- chk_malloc(sizeof *tft));
+ chk_calloc(1, sizeof *tft));
ffi_type *ft = coerce(ffi_type *, chk_calloc(1, sizeof *ft));
cnum nmemb = c_num(length(types)), i;
@@ -944,7 +944,7 @@ static val make_ffi_type_array(val syntax, val lisp_type,
val dim, val eltypes)
{
struct txr_ffi_type *tft = coerce(struct txr_ffi_type *,
- chk_malloc(sizeof *tft));
+ chk_calloc(1, sizeof *tft));
ffi_type *ft = coerce(ffi_type *, chk_calloc(1, sizeof *ft));
cnum nelem = c_num(dim), i;
@@ -965,8 +965,6 @@ static val make_ffi_type_array(val syntax, val lisp_type,
tft->alloc = ffi_fixed_alloc;
tft->free = free;
tft->fill = ffi_array_fill;
- tft->size = 0;
- tft->align = 0;
for (i = 0; i < nelem; i++) {
val eltype = pop(&eltypes);