com php-src: Fix #70173: ZVAL_COPY_VALUE_EX broken fo r 32bit Solaris Sparc: Zend/tests/bug7017 3.phpt Zend/zend_types.h
| From: | Anatol Belski | Date: | Sun, 09 Aug 2015 13:01:37 +0000 |
| Subject: | com php-src: Fix #70173: ZVAL_COPY_VALUE_EX broken fo r 32bit Solaris Sparc: Zend/tests/bug7017 3.phpt Zend/zend_types.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88627@lists.php.net to get a copy of this message | ||
Commit: 79f64e5e673e15c1512eebfd9ce2df719b4a3036
Author: Christoph M. Becker <cmb@php.net> Sun, 9 Aug 2015 14:48:17 +0200
Committer: Christoph M. Becker <cmbecker69@gmx.de> Sun, 9 Aug 2015 15:01:37 +0200
Parents: 64a51893585e00e69f5de4520ac6209363f9c6ff
Branches: PHP-7.0.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=79f64e5e673e15c1512eebfd9ce2df719b4a3036
Log:
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.
Bugs:
https://bugs.php.net/70173
Changed paths:
A Zend/tests/bug70173.phpt
M Zend/zend_types.h
Diff:
diff --git a/Zend/tests/bug70173.phpt b/Zend/tests/bug70173.phpt
new file mode 100644
index 0000000..7679734
--- /dev/null
+++ b/Zend/tests/bug70173.phpt
@@ -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)
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
index d002566..50a4698 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 { \