Skip to content

Commit 5d0d812

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
2 parents d207fd4 + 47fb17b commit 5d0d812

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2018, PHP 7.2.9
44

5+
- Filter:
6+
. Fixed bug #76366 (References in sub-array for filtering breaks the filter).
7+
(ZiHang Gao)
8+
59
- PDO_Firebird:
610
. Fixed bug #76488 (Memory leak when fetching a BLOB field). (Simonov Denis)
711

ext/filter/filter.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,9 @@ static void php_filter_call(zval *filtered, zend_long filter, zval *filter_args,
621621
}
622622

623623
if ((option = zend_hash_str_find(HASH_OF(filter_args), "options", sizeof("options") - 1)) != NULL) {
624+
/* avoid reference type */
625+
ZVAL_DEREF(option);
626+
624627
if (filter != FILTER_CALLBACK) {
625628
if (Z_TYPE_P(option) == IS_ARRAY) {
626629
options = option;

ext/filter/tests/bug76366.phpt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Bug #76366 (references in sub-array for filtering breaks the filter)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('filter')) die('skip filter extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
10+
#array to filter
11+
$data = ['foo' => 6];
12+
13+
#filter args
14+
$args = [
15+
'foo'=> [
16+
'filter' => FILTER_VALIDATE_INT,
17+
'flags' => FILTER_FORCE_ARRAY
18+
]
19+
];
20+
21+
$args['foo']['options'] = [];
22+
23+
#create reference
24+
$options = &$args['foo']['options'];
25+
26+
#set options
27+
$options['min_range'] = 1;
28+
$options['max_range'] = 5;
29+
30+
#show the filter result
31+
var_dump(filter_var_array($data, $args));
32+
?>
33+
--EXPECT--
34+
array(1) {
35+
["foo"]=>
36+
array(1) {
37+
[0]=>
38+
bool(false)
39+
}
40+
}

0 commit comments

Comments
 (0)