History log of /PHP-8.4/ext/ffi/tests/gh16013.phpt (Results 1 – 1 of 1)
Revision Date Author Comments
# 99a14b80 25-Dec-2024 Niels Dossche <7771979+nielsdos@users.noreply.github.com>

Fix GH-16013 and bug #80857: Big endian issues

The FFI call return values follow widening rules.
We must widen to `ffi_arg` in the case we're handling a return value for types shorter th

Fix GH-16013 and bug #80857: Big endian issues

The FFI call return values follow widening rules.
We must widen to `ffi_arg` in the case we're handling a return value for types shorter than the machine width.
From http://www.chiark.greenend.org.uk/doc/libffi-dev/html/The-Closure-API.html:
> In most cases, ret points to an object of exactly the size of the type specified when cif was constructed.
> However, integral types narrower than the system register size are widened.
> In these cases your program may assume that ret points to an ffi_arg object.

If we don't do this, we get wrong values when reading the return values.

Closes GH-17255.

Co-authored-by: Dmitry Stogov <dmitry@zend.com>

show more ...