Skip to content

Commit eb244fc

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

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ PHP NEWS
3434
- Session:
3535
. Fixed bug GH-13856 (Member access within null pointer of type 'ps_files' in
3636
ext/session/mod_files.c). (nielsdos)
37+
. Fixed bug GH-13891 (memleak and segfault when using ini_set with
38+
session.trans_sid_hosts). (nielsdos, kamil-tekiela).
3739

3840
- Streams:
3941
. Fixed bug GH-13264 (Part 1 - Memory leak on stream filter failure).

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)