Fix #70173: ZVAL_COPY_VALUE_EX broken for 32bit Solaris Sparc

On 32bit big endian architectures the high word of a zend_value is copied
twice, instead of copying both words. Let's fix it.
This commit is contained in:
Christoph M. Becker 2015-08-09 14:48:17 +02:00 committed by Christoph M. Becker
parent 64a5189358
commit 79f64e5e67
2 changed files with 24 additions and 1 deletions

13
Zend/tests/bug70173.phpt Normal file
View File

@ -0,0 +1,13 @@
--TEST--
Bug #70173 (ZVAL_COPY_VALUE_EX broken for 32bit Solaris Sparc)
--SKIPIF--
<?php
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
?>
--FILE--
<?php
$var = 2900000000;
var_dump($var);
?>
--EXPECT--
float(2900000000)

View File

@ -822,13 +822,23 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) {
}
#if SIZEOF_SIZE_T == 4
# define ZVAL_COPY_VALUE_EX(z, v, gc, t) \
# ifdef WORDS_BIGENDIAN
# define ZVAL_COPY_VALUE_EX(z, v, gc, t) \
do { \
uint32_t _w1 = v->value.ww.w1; \
Z_COUNTED_P(z) = gc; \
z->value.ww.w1 = _w1; \
Z_TYPE_INFO_P(z) = t; \
} while (0)
# else
# define ZVAL_COPY_VALUE_EX(z, v, gc, t) \
do { \
uint32_t _w2 = v->value.ww.w2; \
Z_COUNTED_P(z) = gc; \
z->value.ww.w2 = _w2; \
Z_TYPE_INFO_P(z) = t; \
} while (0)
# endif
#elif SIZEOF_SIZE_T == 8
# define ZVAL_COPY_VALUE_EX(z, v, gc, t) \
do { \