Skip to content

Commit 0805e13

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents 2046b3c + 6fcde56 commit 0805e13

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ PHP NEWS
3131
- Standard:
3232
. Fixed bug #76342 (file_get_contents waits twice specified timeout).
3333
(Thomas Calvet)
34+
. Fixed bug #78612 (strtr leaks memory when integer keys are used and the
35+
subject string shorter). (Nikita)
3436

3537
26 Sep 2019, PHP 7.3.10
3638

ext/standard/string.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,6 +3068,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
30683068
len = ZSTR_LEN(key_used);
30693069
if (UNEXPECTED(len > slen)) {
30703070
/* skip long patterns */
3071+
zend_string_release(key_used);
30713072
continue;
30723073
}
30733074
if (len > maxlen) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #78612 (strtr leaks memory when integer keys are used and the subject string shorter).
3+
--FILE--
4+
<?php
5+
6+
$find_replace = array();
7+
$_a = 7111222333000001;
8+
$_b = 5000001;
9+
10+
for ($j=0; $j<10; $j++) {
11+
$find_replace[$_a + $j] = $_b + $j;
12+
}
13+
14+
echo strtr('Hello', $find_replace), "\n";
15+
16+
?>
17+
--EXPECT--
18+
Hello

0 commit comments

Comments
 (0)