summaryrefslogtreecommitdiff
path: root/ext/ffi/ffi.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2019-09-10 11:23:12 +0300
committerDmitry Stogov <dmitry@zend.com>2019-09-10 11:23:12 +0300
commit21c3cdf66824a0522779fa252a675173d02dc724 (patch)
tree2608e040d7d5e0a43b85c4a36c4b56a95a3a8948 /ext/ffi/ffi.c
parent825dac1445144e9c78dc74782eefecc8979f02cc (diff)
downloadphp-git-21c3cdf66824a0522779fa252a675173d02dc724.tar.gz
NEWS entry, test and minor cleanup for FFI::isNull()
Diffstat (limited to 'ext/ffi/ffi.c')
-rw-r--r--ext/ffi/ffi.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c
index 83838ae6a1..1d6f84b6b2 100644
--- a/ext/ffi/ffi.c
+++ b/ext/ffi/ffi.c
@@ -4364,8 +4364,8 @@ ZEND_METHOD(FFI, string) /* {{{ */
ZEND_METHOD(FFI, isNull) /* {{{ */
{
zval *zv;
+ zend_ffi_cdata *cdata;
zend_ffi_type *type;
- void *ptr = NULL;
ZEND_FFI_VALIDATE_API_RESTRICTION();
ZEND_PARSE_PARAMETERS_START(1, 1)
@@ -4373,20 +4373,20 @@ ZEND_METHOD(FFI, isNull) /* {{{ */
ZEND_PARSE_PARAMETERS_END();
ZVAL_DEREF(zv);
- if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJCE_P(zv) == zend_ffi_cdata_ce) {
- zend_ffi_cdata *cdata = (zend_ffi_cdata*)Z_OBJ_P(zv);
- type = ZEND_FFI_TYPE(cdata->type);
- ptr = cdata->ptr;
- } else {
+ if (Z_TYPE_P(zv) != IS_OBJECT || Z_OBJCE_P(zv) != zend_ffi_cdata_ce) {
zend_wrong_parameter_class_error(1, "FFI\\CData", zv);
return;
}
+ cdata = (zend_ffi_cdata*)Z_OBJ_P(zv);
+ type = ZEND_FFI_TYPE(cdata->type);
+
if (type->kind != ZEND_FFI_TYPE_POINTER){
zend_throw_error(zend_ffi_exception_ce, "FFI\\Cdata is not a pointer");
+ return;
}
- RETURN_BOOL(*(void**)ptr == NULL);
+ RETURN_BOOL(*(void**)cdata->ptr == NULL);
}
/* }}} */