[php-src] Issue #11515: PHP FFI bug
| From: | xywf221 | Date: | Fri, 23 Jun 2023 12:42:34 +0000 |
| Subject: | [php-src] Issue #11515: PHP FFI bug | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244795@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11515
Author: xywf221
### Description
The following code:
```php
<?php
$ffi = FFI::cdef("
int printf(const char *format, ...);
");
$name = $ffi->new('char[4]');
FFI::memcpy($name, 'abc', 3);
$abc = FFI::cast('char*', $name);
$ffi->printf("symbol = %s\n", $abc);
$ffi->printf("symbol2 = %s\n", ffi_new_char());
function ffi_new_char()
{
$name = FFI::new('char[4]');
FFI::memcpy($name, 'abc', 3);
return FFI::cast('char*', $name);
}
```
Resulted in this output:
```
symbol = abc
symbol2 = (0`
```
But I expected this output instead:
```
symbol = abc
symbol2 = abc
```
### PHP Version
PHP 8.2.6
### Operating System
MacOS 13.2.1 (22D68)