Skip to content

Commit

Permalink
Fixed bug #76366 (references in sub-array for filtering breaks the fi…
Browse files Browse the repository at this point in the history
…lter)
  • Loading branch information
cdoco authored and nikic committed Jul 7, 2018
1 parent ea24847 commit 47fb17b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 7.1.21

- Filter:
. Fixed bug #76366 (References in sub-array for filtering breaks the filter).
(ZiHang Gao)

- PDO_Firebird:
. Fixed bug #76488 (Memory leak when fetching a BLOB field). (Simonov Denis)

Expand Down
3 changes: 3 additions & 0 deletions ext/filter/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ static void php_filter_call(zval *filtered, zend_long filter, zval *filter_args,
}

if ((option = zend_hash_str_find(HASH_OF(filter_args), "options", sizeof("options") - 1)) != NULL) {
/* avoid reference type */
ZVAL_DEREF(option);

if (filter != FILTER_CALLBACK) {
if (Z_TYPE_P(option) == IS_ARRAY) {
options = option;
Expand Down
40 changes: 40 additions & 0 deletions ext/filter/tests/bug76366.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--TEST--
Bug #76366 (references in sub-array for filtering breaks the filter)
--SKIPIF--
<?php
if (!extension_loaded('filter')) die('skip filter extension not available');
?>
--FILE--
<?php

#array to filter
$data = ['foo' => 6];

#filter args
$args = [
'foo'=> [
'filter' => FILTER_VALIDATE_INT,
'flags' => FILTER_FORCE_ARRAY
]
];

$args['foo']['options'] = [];

#create reference
$options = &$args['foo']['options'];

#set options
$options['min_range'] = 1;
$options['max_range'] = 5;

#show the filter result
var_dump(filter_var_array($data, $args));
?>
--EXPECT--
array(1) {
["foo"]=>
array(1) {
[0]=>
bool(false)
}
}

0 comments on commit 47fb17b

Please sign in to comment.