Skip to content

Commit 62cdaac

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix memory leaks with string function name lookups
2 parents 59651ee + cac4290 commit 62cdaac

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

ext/soap/soap.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,7 @@ PHP_METHOD(SoapServer, addFunction)
11631163
key = zend_string_tolower(Z_STR_P(tmp_function));
11641164

11651165
if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) {
1166+
zend_string_release_ex(key, false);
11661167
zend_type_error("SoapServer::addFunction(): Function \"%s\" not found", Z_STRVAL_P(tmp_function));
11671168
SOAP_SERVER_END_CODE();
11681169
RETURN_THROWS();
@@ -1181,6 +1182,7 @@ PHP_METHOD(SoapServer, addFunction)
11811182
key = zend_string_tolower(Z_STR_P(function_name));
11821183

11831184
if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) {
1185+
zend_string_release_ex(key, false);
11841186
zend_argument_type_error(1, "must be a valid function name, function \"%s\" not found", Z_STRVAL_P(function_name));
11851187
SOAP_SERVER_END_CODE();
11861188
RETURN_THROWS();
@@ -1505,8 +1507,7 @@ PHP_METHOD(SoapServer, handle)
15051507
}
15061508
}
15071509
#endif
1508-
zend_string *fn_name = zend_string_tolower(Z_STR(h->function_name));
1509-
if (zend_hash_exists(function_table, fn_name) ||
1510+
if (zend_hash_find_ptr_lc(function_table, Z_STR(h->function_name)) != NULL ||
15101511
((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&
15111512
zend_hash_str_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1))) {
15121513
if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) {
@@ -1522,25 +1523,21 @@ PHP_METHOD(SoapServer, handle)
15221523
instanceof_function(Z_OBJCE(h->retval), soap_fault_class_entry)) {
15231524
php_output_discard();
15241525
soap_server_fault_ex(function, &h->retval, h);
1525-
zend_string_release(fn_name);
15261526
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(soap_obj);}
15271527
goto fail;
15281528
} else if (EG(exception)) {
15291529
php_output_discard();
15301530
_soap_server_exception(service, function, ZEND_THIS);
1531-
zend_string_release(fn_name);
15321531
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(soap_obj);}
15331532
goto fail;
15341533
}
15351534
} else if (h->mustUnderstand) {
15361535
soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL);
15371536
}
1538-
zend_string_release(fn_name);
15391537
}
15401538
}
15411539

1542-
zend_string *fn_name = zend_string_tolower(Z_STR(function_name));
1543-
if (zend_hash_exists(function_table, fn_name) ||
1540+
if (zend_hash_find_ptr_lc(function_table, Z_STR(function_name)) != NULL ||
15441541
((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&
15451542
zend_hash_str_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1))) {
15461543
if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) {
@@ -1557,7 +1554,6 @@ PHP_METHOD(SoapServer, handle)
15571554
} else {
15581555
php_error(E_ERROR, "Function '%s' doesn't exist", Z_STRVAL(function_name));
15591556
}
1560-
zend_string_release(fn_name);
15611557

15621558
if (EG(exception)) {
15631559
if (!zend_is_unwind_exit(EG(exception))) {

0 commit comments

Comments
 (0)