Skip to content

Commit c0a54f4

Browse files
committed
Merge branch 'PHP-7.4'
2 parents b146816 + 1f0ffec commit c0a54f4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ext/standard/string.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,6 +2847,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
28472847
len = ZSTR_LEN(key_used);
28482848
if (UNEXPECTED(len > slen)) {
28492849
/* skip long patterns */
2850+
zend_string_release(key_used);
28502851
continue;
28512852
}
28522853
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)