From: Nikita Popov Date: Thu, 20 Jun 2019 12:52:12 +0000 (+0200) Subject: FFI: Use signed arithmetic for pointer offset X-Git-Tag: php-7.4.0alpha2~32 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f127d77eefad4b641b2befcbab13f16a624e7424;p=php FFI: Use signed arithmetic for pointer offset offset can be negative here, using signed arithmetic avoids ubsan warnings. --- diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 1b016c00a6..20a215a42a 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -1638,7 +1638,7 @@ static zend_object* zend_ffi_add(zend_ffi_cdata *base_cdata, zend_ffi_type *base } cdata->ptr = &cdata->ptr_holder; cdata->ptr_holder = ptr + - offset * ZEND_FFI_TYPE(ptr_type)->size; + (ptrdiff_t) (offset * ZEND_FFI_TYPE(ptr_type)->size); cdata->flags = base_cdata->flags & ZEND_FFI_FLAG_CONST; return &cdata->std; }