fix size of array elements
authorMichael Wallner <mike@php.net>
Tue, 5 Sep 2017 10:14:24 +0000 (12:14 +0200)
committerMichael Wallner <mike@php.net>
Tue, 5 Sep 2017 10:14:24 +0000 (12:14 +0200)
src/libffi.c
src/libjit.c
src/types/decl_arg.c

index d01d907..2ba4831 100644 (file)
@@ -217,7 +217,7 @@ static ffi_type **psi_ffi_struct_type_elements(struct psi_decl_struct *strct) {
                        maxalign = type->alignment;
                }
 
-               assert(type->size == darg->layout->len);
+               assert(type->size <= darg->layout->len);
                if ((padding = psi_offset_padding(darg->layout->pos - offset, type->alignment))) {
                        if (nels + padding + 1 > argc) {
                                argc += padding;
index 52562af..7c48191 100644 (file)
@@ -151,7 +151,7 @@ static unsigned psi_jit_struct_type_elements(struct psi_decl_struct *strct,
                        maxalign = alignment;
                }
 
-               assert(jit_type_get_size(type) == darg->layout->len);
+               assert(jit_type_get_size(type) <= darg->layout->len);
                if ((padding = psi_offset_padding(darg->layout->pos - offset, alignment))) {
                        if (nels + padding > argc) {
                                argc += padding;
index 61aacef..0423c97 100644 (file)
@@ -165,7 +165,7 @@ size_t psi_decl_arg_get_align(struct psi_decl_arg *darg)
        size_t align;
 
        if (darg->var->pointer_level
-                       && (!darg->var->array_size || darg->var->pointer_level > 2)) {
+                       && (!darg->var->array_size || darg->var->pointer_level > 1)) {
                align = psi_t_alignment(PSI_T_POINTER);
        } else {
                align = psi_decl_type_get_align(darg->type);
@@ -180,7 +180,7 @@ size_t psi_decl_arg_get_size(struct psi_decl_arg *darg)
        struct psi_decl_type *real = psi_decl_type_get_real(darg->type);
 
        if (darg->var->array_size) {
-               if (darg->var->pointer_level > 2) {
+               if (darg->var->pointer_level > 1) {
                        size = psi_t_size(PSI_T_POINTER) * darg->var->array_size;
                } else {
                        size = psi_t_size(real->type) * darg->var->array_size;