diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-04-28 06:12:13 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-04-28 06:12:13 -0700 |
commit | 4cb7a078887e649221a164f77262a92f23c39ee5 (patch) | |
tree | 4e3e8b99da703044b3410844efda11a801f51c25 | |
parent | 007a5f4bb56c17947e3d39435ca80de580c615c0 (diff) | |
download | txr-4cb7a078887e649221a164f77262a92f23c39ee5.tar.gz txr-4cb7a078887e649221a164f77262a92f23c39ee5.tar.bz2 txr-4cb7a078887e649221a164f77262a92f23c39ee5.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.
-rw-r--r-- | ffi.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -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); |