File tree Expand file tree Collapse file tree 3 files changed +37
-7
lines changed Expand file tree Collapse file tree 3 files changed +37
-7
lines changed Original file line number Diff line number Diff line change 3
3
?? ??? ????, PHP 7.4.0RC2
4
4
5
5
- FFI:
6
+ . Added missing FFI::isNull(). (Philip Hofstetter)
6
7
. Fixed bug #78488 (OOB in ZEND_FUNCTION(ffi_trampoline)). (Dmitry)
7
8
8
9
- Opcache:
Original file line number Diff line number Diff line change @@ -4364,29 +4364,29 @@ ZEND_METHOD(FFI, string) /* {{{ */
4364
4364
ZEND_METHOD (FFI , isNull ) /* {{{ */
4365
4365
{
4366
4366
zval * zv ;
4367
+ zend_ffi_cdata * cdata ;
4367
4368
zend_ffi_type * type ;
4368
- void * ptr = NULL ;
4369
4369
4370
4370
ZEND_FFI_VALIDATE_API_RESTRICTION ();
4371
4371
ZEND_PARSE_PARAMETERS_START (1 , 1 )
4372
4372
Z_PARAM_ZVAL (zv );
4373
4373
ZEND_PARSE_PARAMETERS_END ();
4374
4374
4375
4375
ZVAL_DEREF (zv );
4376
- if (Z_TYPE_P (zv ) == IS_OBJECT && Z_OBJCE_P (zv ) == zend_ffi_cdata_ce ) {
4377
- zend_ffi_cdata * cdata = (zend_ffi_cdata * )Z_OBJ_P (zv );
4378
- type = ZEND_FFI_TYPE (cdata -> type );
4379
- ptr = cdata -> ptr ;
4380
- } else {
4376
+ if (Z_TYPE_P (zv ) != IS_OBJECT || Z_OBJCE_P (zv ) != zend_ffi_cdata_ce ) {
4381
4377
zend_wrong_parameter_class_error (1 , "FFI\\CData" , zv );
4382
4378
return ;
4383
4379
}
4384
4380
4381
+ cdata = (zend_ffi_cdata * )Z_OBJ_P (zv );
4382
+ type = ZEND_FFI_TYPE (cdata -> type );
4383
+
4385
4384
if (type -> kind != ZEND_FFI_TYPE_POINTER ){
4386
4385
zend_throw_error (zend_ffi_exception_ce , "FFI\\Cdata is not a pointer" );
4386
+ return ;
4387
4387
}
4388
4388
4389
- RETURN_BOOL (* (void * * )ptr == NULL );
4389
+ RETURN_BOOL (* (void * * )cdata -> ptr == NULL );
4390
4390
}
4391
4391
/* }}} */
4392
4392
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ FFI 045: FFI::isNull()
3
+ --SKIPIF--
4
+ <?php require_once ('skipif.inc ' ); ?>
5
+ --INI--
6
+ ffi.enable=1
7
+ --FILE--
8
+ <?php
9
+ var_dump (FFI ::isNull (FFI ::new ("int* " )));
10
+ $ i = FFI ::new ("int " );
11
+ var_dump (FFI ::isNull (FFI ::addr ($ i )));
12
+ try {
13
+ var_dump (FFI ::isNull (null ));
14
+ } catch (Throwable $ e ) {
15
+ echo get_class ($ e ) . ": " . $ e ->getMessage ()."\n" ;
16
+ }
17
+ try {
18
+ var_dump (FFI ::isNull (FFI ::new ("int[0] " )));
19
+ } catch (Throwable $ e ) {
20
+ echo get_class ($ e ) . ": " . $ e ->getMessage ()."\n" ;
21
+ }
22
+ ?>
23
+ --EXPECTF--
24
+ bool(true)
25
+ bool(false)
26
+
27
+ Warning: FFI::isNull() expects parameter 1 to be FFI\CData, null given in %s045.php on line %d
28
+ NULL
29
+ FFI\Exception: FFI\Cdata is not a pointer
You can’t perform that action at this time.
0 commit comments