summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2018-07-07 12:07:52 +0200
committerNikita Popov <nikita.ppv@gmail.com>2018-07-07 12:08:02 +0200
commit5d0d812a53c2961ec8733230c192b711c65164cd (patch)
treefbc4b26edaeb787a09d1a7165627ad090ec002b9 /ext
parentd207fd449cd188085b600783bec7574269392ed2 (diff)
parent47fb17b108b401d8dbb5f1b94ec99ea0d020288a (diff)
downloadphp-git-5d0d812a53c2961ec8733230c192b711c65164cd.tar.gz
Merge branch 'PHP-7.1' into PHP-7.2
Diffstat (limited to 'ext')
-rw-r--r--ext/filter/filter.c3
-rw-r--r--ext/filter/tests/bug76366.phpt40
2 files changed, 43 insertions, 0 deletions
diff --git a/ext/filter/filter.c b/ext/filter/filter.c
index a4ca1e0a99..5a34caaa24 100644
--- a/ext/filter/filter.c
+++ b/ext/filter/filter.c
@@ -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;
diff --git a/ext/filter/tests/bug76366.phpt b/ext/filter/tests/bug76366.phpt
new file mode 100644
index 0000000000..56cbb9db54
--- /dev/null
+++ b/ext/filter/tests/bug76366.phpt
@@ -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)
+ }
+}