@@ -1169,20 +1169,10 @@ static zval *zend_ffi_cdata_read_field(zend_object *obj, zend_string *field_name
1169
1169
if (cache_slot && * cache_slot == type ) {
1170
1170
field = * (cache_slot + 1 );
1171
1171
} else {
1172
+ if (type -> kind == ZEND_FFI_TYPE_POINTER ) {
1173
+ type = ZEND_FFI_TYPE (type -> pointer .type );
1174
+ }
1172
1175
if (UNEXPECTED (type -> kind != ZEND_FFI_TYPE_STRUCT )) {
1173
- if (type -> kind == ZEND_FFI_TYPE_POINTER ) {
1174
- /* transparently dereference the pointer */
1175
- if (UNEXPECTED (!ptr )) {
1176
- zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1177
- return & EG (uninitialized_zval );
1178
- }
1179
- ptr = (void * )(* (char * * )ptr );
1180
- if (UNEXPECTED (!ptr )) {
1181
- zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1182
- return & EG (uninitialized_zval );
1183
- }
1184
- type = ZEND_FFI_TYPE (type -> pointer .type );
1185
- }
1186
1176
if (UNEXPECTED (type -> kind != ZEND_FFI_TYPE_STRUCT )) {
1187
1177
zend_throw_error (zend_ffi_exception_ce , "Attempt to read field '%s' of non C struct/union" , ZSTR_VAL (field_name ));
1188
1178
return & EG (uninitialized_zval );
@@ -1201,6 +1191,20 @@ static zval *zend_ffi_cdata_read_field(zend_object *obj, zend_string *field_name
1201
1191
}
1202
1192
}
1203
1193
1194
+ if (ZEND_FFI_TYPE (cdata -> type )-> kind == ZEND_FFI_TYPE_POINTER ) {
1195
+ /* transparently dereference the pointer */
1196
+ if (UNEXPECTED (!ptr )) {
1197
+ zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1198
+ return & EG (uninitialized_zval );
1199
+ }
1200
+ ptr = (void * )(* (char * * )ptr );
1201
+ if (UNEXPECTED (!ptr )) {
1202
+ zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1203
+ return & EG (uninitialized_zval );
1204
+ }
1205
+ type = ZEND_FFI_TYPE (type -> pointer .type );
1206
+ }
1207
+
1204
1208
#if 0
1205
1209
if (UNEXPECTED (!ptr )) {
1206
1210
zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
@@ -1238,20 +1242,10 @@ static zval *zend_ffi_cdata_write_field(zend_object *obj, zend_string *field_nam
1238
1242
if (cache_slot && * cache_slot == type ) {
1239
1243
field = * (cache_slot + 1 );
1240
1244
} else {
1245
+ if (type -> kind == ZEND_FFI_TYPE_POINTER ) {
1246
+ type = ZEND_FFI_TYPE (type -> pointer .type );
1247
+ }
1241
1248
if (UNEXPECTED (type -> kind != ZEND_FFI_TYPE_STRUCT )) {
1242
- if (type -> kind == ZEND_FFI_TYPE_POINTER ) {
1243
- /* transparently dereference the pointer */
1244
- if (UNEXPECTED (!ptr )) {
1245
- zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1246
- return value ;
1247
- }
1248
- ptr = (void * )(* (char * * )ptr );
1249
- if (UNEXPECTED (!ptr )) {
1250
- zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1251
- return value ;
1252
- }
1253
- type = ZEND_FFI_TYPE (type -> pointer .type );
1254
- }
1255
1249
if (UNEXPECTED (type -> kind != ZEND_FFI_TYPE_STRUCT )) {
1256
1250
zend_throw_error (zend_ffi_exception_ce , "Attempt to assign field '%s' of non C struct/union" , ZSTR_VAL (field_name ));
1257
1251
return value ;
@@ -1270,6 +1264,19 @@ static zval *zend_ffi_cdata_write_field(zend_object *obj, zend_string *field_nam
1270
1264
}
1271
1265
}
1272
1266
1267
+ if (ZEND_FFI_TYPE (cdata -> type )-> kind == ZEND_FFI_TYPE_POINTER ) {
1268
+ /* transparently dereference the pointer */
1269
+ if (UNEXPECTED (!ptr )) {
1270
+ zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1271
+ return value ;
1272
+ }
1273
+ ptr = (void * )(* (char * * )ptr );
1274
+ if (UNEXPECTED (!ptr )) {
1275
+ zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1276
+ return value ;
1277
+ }
1278
+ }
1279
+
1273
1280
#if 0
1274
1281
if (UNEXPECTED (!ptr )) {
1275
1282
zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
0 commit comments