]> granicus.if.org Git - php/commitdiff
Fix in_array (strict) with references
authorNikita Popov <nikic@php.net>
Sun, 25 May 2014 16:19:00 +0000 (18:19 +0200)
committerNikita Popov <nikic@php.net>
Sun, 25 May 2014 16:19:00 +0000 (18:19 +0200)
ext/standard/array.c
ext/standard/tests/array/in_array_with_ref.phpt [new file with mode: 0644]

index 97ab2583f633774155246da1e487bc4e3c90eea0..689d083b06237059c866df3b50552763706bcfb0 100644 (file)
@@ -1165,6 +1165,7 @@ static void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior) /* {{{
 
        if (strict) {
                ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
+                       ZVAL_DEREF(entry);
                        is_identical_function(&res, value, entry TSRMLS_CC);
                        if (Z_TYPE(res) == IS_TRUE) {
                                if (behavior == 0) {
diff --git a/ext/standard/tests/array/in_array_with_ref.phpt b/ext/standard/tests/array/in_array_with_ref.phpt
new file mode 100644 (file)
index 0000000..2ad3667
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+in_array() with references
+--FILE--
+<?php
+
+$value = 42;
+$array = [&$value];
+var_dump(in_array(42, $array, false));
+var_dump(in_array(42, $array, true));
+
+?>
+--EXPECT--
+bool(true)
+bool(true)