summaryrefslogtreecommitdiff
path: root/Zend/tests/array_hash_zero.phpt
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2015-03-18 22:25:55 +0100
committerBob Weinand <bobwei9@hotmail.com>2015-03-18 22:25:55 +0100
commitdac2b060e4c55db2f1b309125c9506ecc8f3200e (patch)
tree24e282b111cea03831339714a3ede99c9031b44d /Zend/tests/array_hash_zero.phpt
parenteb5dfedb6b4742640fc447d5a03dc575d5f569f1 (diff)
downloadphp-git-dac2b060e4c55db2f1b309125c9506ecc8f3200e.tar.gz
Remove bogus ZEND_ASSERT(hash != 0)
There's always a possibility that the has will end up as equal to zero due to overflowing. See the tests for strings whose hash overflow. Yes, there's a check for whether the hash already was calculated... and strings with a hash equal to zero always need the hash recalculated, in one of 2^32 respectively 2^64 cases - which should not be a major issue.
Diffstat (limited to 'Zend/tests/array_hash_zero.phpt')
-rw-r--r--Zend/tests/array_hash_zero.phpt20
1 files changed, 20 insertions, 0 deletions
diff --git a/Zend/tests/array_hash_zero.phpt b/Zend/tests/array_hash_zero.phpt
new file mode 100644
index 0000000000..337cdfd1a2
--- /dev/null
+++ b/Zend/tests/array_hash_zero.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Accept hashes being equal to zero
+--FILE--
+<?php
+
+$hashes = [
+ "\x8e\x1a\x63\x0f\x61" => 32,
+ "\xf7\x17\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x6b\x03\x6a\x13\x63\x17\x6b\x1d\x67" => 64,
+];
+
+foreach ($hashes as $hash => $bits) {
+ var_dump($hashes[$hash], $bits);
+}
+
+?>
+--EXPECT--
+int(32)
+int(32)
+int(64)
+int(64)