@@ -1215,20 +1215,10 @@ static zval *zend_ffi_cdata_read_field(zend_object *obj, zend_string *field_name
1215
1215
if (cache_slot && * cache_slot == type ) {
1216
1216
field = * (cache_slot + 1 );
1217
1217
} else {
1218
+ if (type -> kind == ZEND_FFI_TYPE_POINTER ) {
1219
+ type = ZEND_FFI_TYPE (type -> pointer .type );
1220
+ }
1218
1221
if (UNEXPECTED (type -> kind != ZEND_FFI_TYPE_STRUCT )) {
1219
- if (type -> kind == ZEND_FFI_TYPE_POINTER ) {
1220
- /* transparently dereference the pointer */
1221
- if (UNEXPECTED (!ptr )) {
1222
- zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1223
- return & EG (uninitialized_zval );
1224
- }
1225
- ptr = (void * )(* (char * * )ptr );
1226
- if (UNEXPECTED (!ptr )) {
1227
- zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1228
- return & EG (uninitialized_zval );
1229
- }
1230
- type = ZEND_FFI_TYPE (type -> pointer .type );
1231
- }
1232
1222
if (UNEXPECTED (type -> kind != ZEND_FFI_TYPE_STRUCT )) {
1233
1223
zend_throw_error (zend_ffi_exception_ce , "Attempt to read field '%s' of non C struct/union" , ZSTR_VAL (field_name ));
1234
1224
return & EG (uninitialized_zval );
@@ -1247,6 +1237,20 @@ static zval *zend_ffi_cdata_read_field(zend_object *obj, zend_string *field_name
1247
1237
}
1248
1238
}
1249
1239
1240
+ if (ZEND_FFI_TYPE (cdata -> type )-> kind == ZEND_FFI_TYPE_POINTER ) {
1241
+ /* transparently dereference the pointer */
1242
+ if (UNEXPECTED (!ptr )) {
1243
+ zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1244
+ return & EG (uninitialized_zval );
1245
+ }
1246
+ ptr = (void * )(* (char * * )ptr );
1247
+ if (UNEXPECTED (!ptr )) {
1248
+ zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1249
+ return & EG (uninitialized_zval );
1250
+ }
1251
+ type = ZEND_FFI_TYPE (type -> pointer .type );
1252
+ }
1253
+
1250
1254
#if 0
1251
1255
if (UNEXPECTED (!ptr )) {
1252
1256
zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
@@ -1284,20 +1288,10 @@ static zval *zend_ffi_cdata_write_field(zend_object *obj, zend_string *field_nam
1284
1288
if (cache_slot && * cache_slot == type ) {
1285
1289
field = * (cache_slot + 1 );
1286
1290
} else {
1291
+ if (type -> kind == ZEND_FFI_TYPE_POINTER ) {
1292
+ type = ZEND_FFI_TYPE (type -> pointer .type );
1293
+ }
1287
1294
if (UNEXPECTED (type -> kind != ZEND_FFI_TYPE_STRUCT )) {
1288
- if (type -> kind == ZEND_FFI_TYPE_POINTER ) {
1289
- /* transparently dereference the pointer */
1290
- if (UNEXPECTED (!ptr )) {
1291
- zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1292
- return value ;
1293
- }
1294
- ptr = (void * )(* (char * * )ptr );
1295
- if (UNEXPECTED (!ptr )) {
1296
- zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1297
- return value ;
1298
- }
1299
- type = ZEND_FFI_TYPE (type -> pointer .type );
1300
- }
1301
1295
if (UNEXPECTED (type -> kind != ZEND_FFI_TYPE_STRUCT )) {
1302
1296
zend_throw_error (zend_ffi_exception_ce , "Attempt to assign field '%s' of non C struct/union" , ZSTR_VAL (field_name ));
1303
1297
return value ;
@@ -1316,6 +1310,19 @@ static zval *zend_ffi_cdata_write_field(zend_object *obj, zend_string *field_nam
1316
1310
}
1317
1311
}
1318
1312
1313
+ if (ZEND_FFI_TYPE (cdata -> type )-> kind == ZEND_FFI_TYPE_POINTER ) {
1314
+ /* transparently dereference the pointer */
1315
+ if (UNEXPECTED (!ptr )) {
1316
+ zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1317
+ return value ;
1318
+ }
1319
+ ptr = (void * )(* (char * * )ptr );
1320
+ if (UNEXPECTED (!ptr )) {
1321
+ zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
1322
+ return value ;
1323
+ }
1324
+ }
1325
+
1319
1326
#if 0
1320
1327
if (UNEXPECTED (!ptr )) {
1321
1328
zend_throw_error (zend_ffi_exception_ce , "NULL pointer dereference" );
0 commit comments