[pypy-commit] cffi default: Fix (corner case, hard to test)

arigo pypy.commits at gmail.com
Mon Mar 11 05:39:44 EDT 2019


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r3242:ff25b4e68195
Date: 2019-03-11 10:27 +0100
http://bitbucket.org/cffi/cffi/changeset/ff25b4e68195/

Log:	Fix (corner case, hard to test)

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -4973,14 +4973,18 @@
                 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)


More information about the pypy-commit mailing list