Skip to content

Commit 1f0ffec

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents 3d89f92 + 0805e13 commit 1f0ffec

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
@@ -3052,6 +3052,7 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
30523052
len = ZSTR_LEN(key_used);
30533053
if (UNEXPECTED(len > slen)) {
30543054
/* skip long patterns */
3055+
zend_string_release(key_used);
30553056
continue;
30563057
}
30573058
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)