Skip to content

Commit 9aeeecc

Browse files
committed
Merge branch 'PHP-7.2'
2 parents 9501304 + 5d0d812 commit 9aeeecc

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
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #76392 (Error relocating sapi/cli/php: unsupported relocation
77
type 37). (Peter Kokot)
88

9+
- Filter:
10+
. Fixed bug #76366 (References in sub-array for filtering breaks the filter).
11+
(ZiHang Gao)
12+
913
- FPM:
1014
. Fixed bug #62596 (getallheaders() missing with PHP-FPM). (Remi)
1115

ext/filter/filter.c

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

616616
if ((option = zend_hash_str_find(HASH_OF(filter_args), "options", sizeof("options") - 1)) != NULL) {
617+
/* avoid reference type */
618+
ZVAL_DEREF(option);
619+
617620
if (filter != FILTER_CALLBACK) {
618621
if (Z_TYPE_P(option) == IS_ARRAY) {
619622
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)