Skip to content

Commit a888c4f

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: ext/soap: Fix memory leaks when calling SoapFault::__construct() twice
2 parents 7c32704 + e9b3643 commit a888c4f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ext/soap/soap.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,17 @@ PHP_METHOD(SoapHeader, __construct)
627627
}
628628
/* }}} */
629629

630+
static void soap_fault_dtor_properties(zval *obj)
631+
{
632+
zval_ptr_dtor(Z_FAULT_STRING_P(obj));
633+
zval_ptr_dtor(Z_FAULT_CODE_P(obj));
634+
zval_ptr_dtor(Z_FAULT_CODENS_P(obj));
635+
zval_ptr_dtor(Z_FAULT_ACTOR_P(obj));
636+
zval_ptr_dtor(Z_FAULT_DETAIL_P(obj));
637+
zval_ptr_dtor(Z_FAULT_NAME_P(obj));
638+
zval_ptr_dtor(Z_FAULT_HEADERFAULT_P(obj));
639+
}
640+
630641
/* {{{ SoapFault constructor */
631642
PHP_METHOD(SoapFault, __construct)
632643
{
@@ -646,6 +657,9 @@ PHP_METHOD(SoapFault, __construct)
646657
Z_PARAM_ZVAL_OR_NULL(headerfault)
647658
ZEND_PARSE_PARAMETERS_END();
648659

660+
/* Delete previously set properties */
661+
soap_fault_dtor_properties(ZEND_THIS);
662+
649663
if (code_str) {
650664
fault_code = ZSTR_VAL(code_str);
651665
fault_code_len = ZSTR_LEN(code_str);

ext/soap/tests/SoapFault/gh14586.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-14586: SoapFault::__construct() leaks memory if called twice
3+
--EXTENSIONS--
4+
soap
5+
--FILE--
6+
<?php
7+
$sf = new SoapFault(null, "x");
8+
$sf->__construct(null, "x");
9+
?>
10+
DONE
11+
--EXPECT--
12+
DONE

0 commit comments

Comments
 (0)