diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-08-24 07:21:19 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-08-24 07:21:19 -0700 |
commit | 365c877d8b31653e12c5284266753671d6515774 (patch) | |
tree | b5f613b8de7dba183b9e0a3047bc1c12f4e6cd4e | |
parent | 401e214ebabadc2d44bdf5115b0f1cc64f6cfb93 (diff) | |
download | txr-365c877d8b31653e12c5284266753671d6515774.tar.gz txr-365c877d8b31653e12c5284266753671d6515774.tar.bz2 txr-365c877d8b31653e12c5284266753671d6515774.zip |
ffi: correct tft->nmemb under zero-bit fields.
* ffi.c (make_ffi_type_struct, make_ffi_type_union): Assign
tft->memb = memb after the loop which compiles the member
types, because memb is decremented in the case of the
zero-width bitfield. This hasn't cause an issue because the
extra members are all zero, so their slot symbol is nil, and
all the relevant operations skip a nil named member.
-rw-r--r-- | ffi.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -3260,7 +3260,6 @@ static val make_ffi_type_struct(val syntax, val lisp_type, tft->alloc = ffi_fixed_alloc; tft->dynsize = ffi_fixed_dynsize; tft->free = free; - tft->memb = memb; tft->incomplete = 1; @@ -3351,6 +3350,8 @@ static val make_ffi_type_struct(val syntax, val lisp_type, tft->by_value_in = 1; } + tft->memb = memb; + if (bit_offs > 0) { bug_unless (bit_offs < 8); offs++; @@ -3429,7 +3430,6 @@ static val make_ffi_type_union(val syntax, val use_existing, val self) tft->alloc = ffi_fixed_alloc; tft->dynsize = ffi_fixed_dynsize; tft->free = free; - tft->memb = memb; tft->incomplete = 1; @@ -3477,6 +3477,8 @@ static val make_ffi_type_union(val syntax, val use_existing, val self) } } + tft->memb = memb; + if (flexp) uw_throwf(error_s, lit("~a: unions cannot contain incomplete member"), |