mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-14286 (ffi enum type (when enum has no name) make memory leak)
This commit is contained in:
commit
b2963e96ee
7 changed files with 85 additions and 2 deletions
4
NEWS
4
NEWS
|
@ -13,6 +13,10 @@ PHP NEWS
|
||||||
. Fixed case when curl_error returns an empty string.
|
. Fixed case when curl_error returns an empty string.
|
||||||
(David Carlier)
|
(David Carlier)
|
||||||
|
|
||||||
|
- FFI:
|
||||||
|
. Fixed bug GH-14286 (ffi enum type (when enum has no name) make memory
|
||||||
|
leak). (nielsdos, dstogov)
|
||||||
|
|
||||||
- Soap:
|
- Soap:
|
||||||
. Fixed bug #55639 (Digest autentication dont work). (nielsdos)
|
. Fixed bug #55639 (Digest autentication dont work). (nielsdos)
|
||||||
|
|
||||||
|
|
|
@ -3582,7 +3582,7 @@ ZEND_METHOD(FFI, scope) /* {{{ */
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
static void zend_ffi_cleanup_dcl(zend_ffi_dcl *dcl) /* {{{ */
|
void zend_ffi_cleanup_dcl(zend_ffi_dcl *dcl) /* {{{ */
|
||||||
{
|
{
|
||||||
if (dcl) {
|
if (dcl) {
|
||||||
zend_ffi_type_dtor(dcl->type);
|
zend_ffi_type_dtor(dcl->type);
|
||||||
|
|
|
@ -97,7 +97,10 @@ declarations:
|
||||||
initializer?
|
initializer?
|
||||||
{zend_ffi_declare(name, name_len, &dcl);}
|
{zend_ffi_declare(name, name_len, &dcl);}
|
||||||
)*
|
)*
|
||||||
)?
|
|
|
||||||
|
/* empty */
|
||||||
|
{if (common_dcl.flags & (ZEND_FFI_DCL_ENUM | ZEND_FFI_DCL_STRUCT | ZEND_FFI_DCL_UNION)) zend_ffi_cleanup_dcl(&common_dcl);}
|
||||||
|
)
|
||||||
";"
|
";"
|
||||||
)*
|
)*
|
||||||
;
|
;
|
||||||
|
|
|
@ -2115,6 +2115,10 @@ static int parse_declarations(int sym) {
|
||||||
}
|
}
|
||||||
zend_ffi_declare(name, name_len, &dcl);
|
zend_ffi_declare(name, name_len, &dcl);
|
||||||
}
|
}
|
||||||
|
} else if (sym == YY__SEMICOLON) {
|
||||||
|
if (common_dcl.flags & (ZEND_FFI_DCL_ENUM | ZEND_FFI_DCL_STRUCT | ZEND_FFI_DCL_UNION)) zend_ffi_cleanup_dcl(&common_dcl);
|
||||||
|
} else {
|
||||||
|
yy_error_sym("unexpected", sym);
|
||||||
}
|
}
|
||||||
if (sym != YY__SEMICOLON) {
|
if (sym != YY__SEMICOLON) {
|
||||||
yy_error_sym("';' expected, got", sym);
|
yy_error_sym("';' expected, got", sym);
|
||||||
|
|
|
@ -208,6 +208,7 @@ typedef struct _zend_ffi_val {
|
||||||
|
|
||||||
zend_result zend_ffi_parse_decl(const char *str, size_t len);
|
zend_result zend_ffi_parse_decl(const char *str, size_t len);
|
||||||
zend_result zend_ffi_parse_type(const char *str, size_t len, zend_ffi_dcl *dcl);
|
zend_result zend_ffi_parse_type(const char *str, size_t len, zend_ffi_dcl *dcl);
|
||||||
|
void zend_ffi_cleanup_dcl(zend_ffi_dcl *dcl);
|
||||||
|
|
||||||
/* parser callbacks */
|
/* parser callbacks */
|
||||||
void ZEND_NORETURN zend_ffi_parser_error(const char *msg, ...);
|
void ZEND_NORETURN zend_ffi_parser_error(const char *msg, ...);
|
||||||
|
|
46
ext/ffi/tests/gh14286_1.phpt
Normal file
46
ext/ffi/tests/gh14286_1.phpt
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
--TEST--
|
||||||
|
GH-14286 (ffi enum type (when enum has no name) make memory leak)
|
||||||
|
--EXTENSIONS--
|
||||||
|
ffi
|
||||||
|
--INI--
|
||||||
|
ffi.enable=1
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$ffi = FFI::cdef("
|
||||||
|
enum {
|
||||||
|
TEST_ONE=1,
|
||||||
|
TEST_TWO=2,
|
||||||
|
};
|
||||||
|
enum TestEnum {
|
||||||
|
TEST_THREE=3,
|
||||||
|
};
|
||||||
|
struct TestStruct {
|
||||||
|
enum {
|
||||||
|
TEST_FOUR=4,
|
||||||
|
} test1;
|
||||||
|
enum TestEnum2 {
|
||||||
|
TEST_FIVE=5,
|
||||||
|
} test2;
|
||||||
|
};
|
||||||
|
typedef enum { TEST_SIX=6 } TestEnum3;
|
||||||
|
struct {
|
||||||
|
int x;
|
||||||
|
};
|
||||||
|
union {
|
||||||
|
int x;
|
||||||
|
};
|
||||||
|
");
|
||||||
|
var_dump($ffi->TEST_ONE);
|
||||||
|
var_dump($ffi->TEST_TWO);
|
||||||
|
var_dump($ffi->TEST_THREE);
|
||||||
|
var_dump($ffi->TEST_FOUR);
|
||||||
|
var_dump($ffi->TEST_FIVE);
|
||||||
|
var_dump($ffi->TEST_SIX);
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
int(1)
|
||||||
|
int(2)
|
||||||
|
int(3)
|
||||||
|
int(4)
|
||||||
|
int(5)
|
||||||
|
int(6)
|
25
ext/ffi/tests/gh14286_2.phpt
Normal file
25
ext/ffi/tests/gh14286_2.phpt
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
--TEST--
|
||||||
|
GH-14286 (ffi enum type (when enum has no name) make memory leak)
|
||||||
|
--EXTENSIONS--
|
||||||
|
ffi
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (PHP_DEBUG || getenv('SKIP_ASAN')) die("xfail: FFI cleanup after parser error is nor implemented");
|
||||||
|
?>
|
||||||
|
--INI--
|
||||||
|
ffi.enable=1
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
try {
|
||||||
|
$ffi = FFI::cdef("
|
||||||
|
enum {
|
||||||
|
TEST_ONE=1,
|
||||||
|
TEST_TWO=2,
|
||||||
|
} x;
|
||||||
|
");
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo $e->getMessage(), "\n";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
Failed resolving C variable 'x'
|
Loading…
Add table
Add a link
Reference in a new issue