cvs: ZendEngine2(PHP_5_2) / zend_execute.c zend_operators.c zend_operators.h zend_vm_def.h zend_vm_execute.h /tests bug46701.phpt
[email protected] ("Felipe Pena") Tue, 06 Jan 2009 01:29:25 -0000
| Newsgroups | php.zend-engine.cvs |
|---|---|
| Message-ID | <cvsfelipe1231205365@cvsserver> |
felipe Tue Jan 6 01:29:25 2009 UTC
Added files: (Branch: PHP_5_2)
/ZendEngine2/tests bug46701.phpt
Modified files:
/ZendEngine2 zend_execute.c zend_operators.c zend_operators.h
zend_vm_def.h zend_vm_execute.h
Log:
MFH:
- Fixed bug #46701 (Creating associative array with long values in the key fails on 32bit linux)
Patch by Shire
felipe-20090106012925.txt
(text/plain, 13.3 KB)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute.c?r1=1.716.2.12.2.30&r2=1.716.2.12.2.31&diff_format=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.716.2.12.2.30 ZendEngine2/zend_execute.c:1.716.2.12.2.31
--- ZendEngine2/zend_execute.c:1.716.2.12.2.30 Wed Dec 31 11:17:33 2008
+++ ZendEngine2/zend_execute.c Tue Jan 6 01:29:20 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.716.2.12.2.30 2008/12/31 11:17:33 sebastian Exp $ */
+/* $Id: zend_execute.c,v 1.716.2.12.2.31 2009/01/06 01:29:20 felipe Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -979,7 +979,7 @@
long index;
if (Z_TYPE_P(dim) == IS_DOUBLE) {
- index = (long)Z_DVAL_P(dim);
+ DVAL_TO_LVAL(Z_DVAL_P(dim), index);
} else {
index = Z_LVAL_P(dim);
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_operators.c?r1=1.208.2.4.2.26&r2=1.208.2.4.2.27&diff_format=u
Index: ZendEngine2/zend_operators.c
diff -u ZendEngine2/zend_operators.c:1.208.2.4.2.26 ZendEngine2/zend_operators.c:1.208.2.4.2.27
--- ZendEngine2/zend_operators.c:1.208.2.4.2.26 Wed Dec 31 11:17:33 2008
+++ ZendEngine2/zend_operators.c Tue Jan 6 01:29:20 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.c,v 1.208.2.4.2.26 2008/12/31 11:17:33 sebastian Exp $ */
+/* $Id: zend_operators.c,v 1.208.2.4.2.27 2009/01/06 01:29:20 felipe Exp $ */
#include <ctype.h>
@@ -186,22 +186,6 @@
} \
}
-#ifdef _WIN64
-# define DVAL_TO_LVAL(d, l) \
- if ((d) > LONG_MAX) { \
- (l) = (long)(unsigned long)(__int64) (d); \
- } else { \
- (l) = (long) (d); \
- }
-#else
-# define DVAL_TO_LVAL(d, l) \
- if ((d) > LONG_MAX) { \
- (l) = (unsigned long) (d); \
- } else { \
- (l) = (long) (d); \
- }
-#endif
-
#define zendi_convert_to_long(op, holder, result) \
if (op == result) { \
convert_to_long(op); \
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_operators.h?r1=1.94.2.4.2.13&r2=1.94.2.4.2.14&diff_format=u
Index: ZendEngine2/zend_operators.h
diff -u ZendEngine2/zend_operators.h:1.94.2.4.2.13 ZendEngine2/zend_operators.h:1.94.2.4.2.14
--- ZendEngine2/zend_operators.h:1.94.2.4.2.13 Wed Dec 31 11:17:33 2008
+++ ZendEngine2/zend_operators.h Tue Jan 6 01:29:20 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.h,v 1.94.2.4.2.13 2008/12/31 11:17:33 sebastian Exp $ */
+/* $Id: zend_operators.h,v 1.94.2.4.2.14 2009/01/06 01:29:20 felipe Exp $ */
#ifndef ZEND_OPERATORS_H
#define ZEND_OPERATORS_H
@@ -75,6 +75,22 @@
ZEND_API zend_bool instanceof_function(zend_class_entry *instance_ce, zend_class_entry *ce TSRMLS_DC);
END_EXTERN_C()
+#ifdef _WIN64
+# define DVAL_TO_LVAL(d, l) \
+ if ((d) > LONG_MAX) { \
+ (l) = (long)(unsigned long)(__int64) (d); \
+ } else { \
+ (l) = (long) (d); \
+ }
+#else
+# define DVAL_TO_LVAL(d, l) \
+ if ((d) > LONG_MAX) { \
+ (l) = (unsigned long) (d); \
+ } else { \
+ (l) = (long) (d); \
+ }
+#endif
+
#define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
#define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.59.2.29.2.60&r2=1.59.2.29.2.61&diff_format=u
Index: ZendEngine2/zend_vm_def.h
diff -u ZendEngine2/zend_vm_def.h:1.59.2.29.2.60 ZendEngine2/zend_vm_def.h:1.59.2.29.2.61
--- ZendEngine2/zend_vm_def.h:1.59.2.29.2.60 Wed Dec 31 11:17:34 2008
+++ ZendEngine2/zend_vm_def.h Tue Jan 6 01:29:20 2009
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_vm_def.h,v 1.59.2.29.2.60 2008/12/31 11:17:34 sebastian Exp $ */
+/* $Id: zend_vm_def.h,v 1.59.2.29.2.61 2009/01/06 01:29:20 felipe Exp $ */
/* If you change this file, please regenerate the zend_vm_execute.h and
* zend_vm_opcodes.h files by running:
@@ -2723,9 +2723,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.62.2.30.2.63&r2=1.62.2.30.2.64&diff_format=u
Index: ZendEngine2/zend_vm_execute.h
diff -u ZendEngine2/zend_vm_execute.h:1.62.2.30.2.63 ZendEngine2/zend_vm_execute.h:1.62.2.30.2.64
--- ZendEngine2/zend_vm_execute.h:1.62.2.30.2.63 Wed Dec 31 11:17:34 2008
+++ ZendEngine2/zend_vm_execute.h Tue Jan 6 01:29:20 2009
@@ -2810,9 +2810,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -3169,9 +3171,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -3528,9 +3532,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -3621,9 +3627,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -3979,9 +3987,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -5440,9 +5450,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -5885,9 +5897,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -6330,9 +6344,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -6423,9 +6439,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -6865,9 +6883,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -9512,9 +9532,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -11032,9 +11054,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -12600,9 +12624,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -13309,9 +13335,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -14609,9 +14637,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -21656,9 +21686,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -23168,9 +23200,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -24727,9 +24761,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -25431,9 +25467,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
@@ -26726,9 +26764,11 @@
}
}
if (offset) {
+ long l;
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
- zend_hash_index_update(Z_ARRVAL_P(array_ptr), (long) Z_DVAL_P(offset), &expr_ptr, sizeof(zval *), NULL);
+ DVAL_TO_LVAL(Z_DVAL_P(offset), l);
+ zend_hash_index_update(Z_ARRVAL_P(array_ptr), l, &expr_ptr, sizeof(zval *), NULL);
break;
case IS_LONG:
case IS_BOOL:
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug46701.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug46701.phpt
+++ ZendEngine2/tests/bug46701.phpt
--TEST--
Bug #46701 (Creating associative array with long values in the key fails on 32bit linux)
--SKIPIF--
<?php if (PHP_INT_MAX != 4) die('skip this test is for 32bit platforms only'); ?>
--FILE--
<?php
$test_array = array(
0xcc5c4600 => 1,
0xce331a00 => 2
);
$test_array[0xce359000] = 3;
var_dump($test_array);
var_dump($test_array[0xce331a00]);
class foo {
public $x;
public function __construct() {
$this->x[0xce359000] = 3;
var_dump($this->x);
}
}
new foo;
?>
--EXPECT--
array(3) {
[-866368000]=>
int(1)
[-835511808]=>
int(2)
[-835350528]=>
int(3)
}
int(2)
array(1) {
[-835350528]=>
int(3)
}