Re: com php-src: 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.: Zend/tests/array_hash_zero.phpt
Zend/zend_str

From: Date: Thu, 19 Mar 2015 08:05:38 +0000
Subject: Re: com php-src: 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.: Zend/tests/array_hash_zero.phpt
Zend/zend_str
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85642@lists.php.net to get a copy of this message
Thanks for discovering this. Dmitry. On Thu, Mar 19, 2015 at 12:25 AM, Bob Weinand <bwoebi@php.net> wrote: > Commit: dac2b060e4c55db2f1b309125c9506ecc8f3200e > Author: Bob Weinand <bobwei9@hotmail.com> Wed, 18 Mar 2015 > 22:25:55 +0100 > Parents: eb5dfedb6b4742640fc447d5a03dc575d5f569f1 > Branches: master > > Link: > > http://git.php.net/?p=php-src.git;a=commitdiff;h=dac2b060e4c55db2f1b309125c9506ecc8f3200e > > Log: > 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. > > Changed paths: > A Zend/tests/array_hash_zero.phpt > M Zend/zend_string.h > > > Diff: > diff --git a/Zend/tests/array_hash_zero.phpt > b/Zend/tests/array_hash_zero.phpt > new file mode 100644 > index 0000000..337cdfd > --- /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) > diff --git a/Zend/zend_string.h b/Zend/zend_string.h > index 746f4b3..b7605ef 100644 > --- a/Zend/zend_string.h > +++ b/Zend/zend_string.h > @@ -284,7 +284,6 @@ static zend_always_inline zend_ulong > zend_inline_hash_func(const char *str, size > EMPTY_SWITCH_DEFAULT_CASE() > } > > - ZEND_ASSERT(hash != 0); > return hash; > } > > > -- > PHP CVS Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.cvs (#85642) next »