summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-08-24 07:21:19 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-08-24 07:21:19 -0700
commit3a9b411d199998504239ecc1ac43f94432b61240 (patch)
treeb5f613b8de7dba183b9e0a3047bc1c12f4e6cd4e
parent8b1d06d905cbb962bcce96c9470492e7b1efb1ee (diff)
downloadtxr-3a9b411d199998504239ecc1ac43f94432b61240.tar.gz
txr-3a9b411d199998504239ecc1ac43f94432b61240.tar.bz2
txr-3a9b411d199998504239ecc1ac43f94432b61240.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.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ffi.c b/ffi.c
index a0f58e9b..dd2fe20d 100644
--- a/ffi.c
+++ b/ffi.c
@@ -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"),