Skip to content

Commit cf31332

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: [ci skip] NEWS Fix GH-13891: memleak and segfault when using ini_set with session.trans_sid_hosts (#13892)
2 parents 0a0e806 + eb244fc commit cf31332

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

ext/session/tests/gh13891.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
GH-13891 (memleak and segfault when using ini_set with session.trans_sid_hosts)
3+
--INI--
4+
session.use_cookies=0
5+
session.use_only_cookies=0
6+
session.use_trans_sid=1
7+
session.trans_sid_hosts=php.net
8+
--EXTENSIONS--
9+
session
10+
--SKIPIF--
11+
<?php include('skipif.inc'); ?>
12+
--FILE--
13+
<?php
14+
// We *must* set it here because the bug only triggers on a runtime edit
15+
ini_set('session.trans_sid_hosts','php.net');
16+
?>
17+
--EXPECT--

ext/standard/url_scanner_ex.re

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@ static int php_ini_on_update_hosts(zend_ini_entry *entry, zend_string *new_value
138138
}
139139
keylen = q - key;
140140
if (keylen > 0) {
141-
tmp_key = zend_string_init(key, keylen, 0);
141+
/* Note: the hash table is persistently allocated, so the strings must be too! */
142+
tmp_key = zend_string_init(key, keylen, true);
142143
zend_hash_add_empty_element(hosts, tmp_key);
143-
zend_string_release_ex(tmp_key, 0);
144+
zend_string_release_ex(tmp_key, true);
144145
}
145146
}
146147
efree(tmp);

0 commit comments

Comments
 (0)