com php-src: FFI: Use signed arithmetic for pointer offset: ext/ffi/ffi.c
| From: | Nikita Popov | Date: | Thu, 20 Jun 2019 14:22:26 +0000 |
| Subject: | com php-src: FFI: Use signed arithmetic for pointer offset: ext/ffi/ffi.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106953@lists.php.net to get a copy of this message | ||
Commit: f127d77eefad4b641b2befcbab13f16a624e7424
Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 20 Jun 2019 14:52:12 +0200
Parents: d4de127dd8db255576ad8c8eeec27e8aef4132e5
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f127d77eefad4b641b2befcbab13f16a624e7424
Log:
FFI: Use signed arithmetic for pointer offset
offset can be negative here, using signed arithmetic avoids ubsan
warnings.
Changed paths:
M ext/ffi/ffi.c
Diff:
diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c
index 1b016c0..20a215a 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;
}