summaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2019-03-11 10:27:38 +0100
committerArmin Rigo <arigo@tunes.org>2019-03-11 10:27:38 +0100
commitdda32c7569ae6b070862d122d2b47114267e1d40 (patch)
treef2acfb73104aa2dba283ea3a36ce1fd03b0fe9ed /c
parent97d81919801352ff0ccfb0d46e19954e7bda8fda (diff)
downloadcffi-dda32c7569ae6b070862d122d2b47114267e1d40.tar.gz
Fix (corner case, hard to test)
Diffstat (limited to 'c')
-rw-r--r--c/_cffi_backend.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
index e163b1d..ac0bc2a 100644
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -4973,14 +4973,18 @@ static PyObject *b_complete_struct_or_union(PyObject *self, PyObject *args)
goto error;
}
}
- else if (ftype->ct_flags & CT_WITH_VAR_ARRAY) {
+ else if (ftype->ct_flags & (CT_STRUCT|CT_UNION)) {
+ if (force_lazy_struct(ftype) < 0) /* for CT_WITH_VAR_ARRAY */
+ return NULL;
+
/* GCC (or maybe C99) accepts var-sized struct fields that are not
the last field of a larger struct. That's why there is no
check here for "last field": we propagate the flag
CT_WITH_VAR_ARRAY to any struct that contains either an open-
ended array or another struct that recursively contains an
open-ended array. */
- ct->ct_flags |= CT_WITH_VAR_ARRAY;
+ if (ftype->ct_flags & CT_WITH_VAR_ARRAY)
+ ct->ct_flags |= CT_WITH_VAR_ARRAY;
}
if (is_union)