diff options
Diffstat (limited to 'ext/ffi/ffi.c')
-rw-r--r-- | ext/ffi/ffi.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 482d7c1a61..0696512342 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -3657,6 +3657,12 @@ ZEND_METHOD(FFI, new) /* {{{ */ } } + if (type->size == 0) { + zend_throw_error(zend_ffi_exception_ce, "Cannot instantiate FFI\\CData of zero size"); + zend_ffi_type_dtor(type_ptr); + return; + } + ptr = pemalloc(type->size, flags & ZEND_FFI_FLAG_PERSISTENT); memset(ptr, 0, type->size); |