From: Christoph M. Becker Date: Sun, 9 Aug 2015 12:48:17 +0000 (+0200) Subject: Fix #70173: ZVAL_COPY_VALUE_EX broken for 32bit Solaris Sparc X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=79f64e5e673e15c1512eebfd9ce2df719b4a3036;p=php 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. --- diff --git a/Zend/tests/bug70173.phpt b/Zend/tests/bug70173.phpt new file mode 100644 index 0000000000..767973449a --- /dev/null +++ b/Zend/tests/bug70173.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #70173 (ZVAL_COPY_VALUE_EX broken for 32bit Solaris Sparc) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +float(2900000000) diff --git a/Zend/zend_types.h b/Zend/zend_types.h index d002566bfe..50a46984a3 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -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 { \