cvs: ZendEngine2(PHP_5_3) / zend_execute.c zend_operators.c zend_operators.h zend_vm_def.h zend_vm_execute.h /tests bug46701.phpt
[email protected] ("Felipe Pena") Mon, 05 Jan 2009 20:31:56 -0000
| Newsgroups | php.zend-engine.cvs |
|---|---|
| Message-ID | <cvsfelipe1231187516@cvsserver> |
felipe Mon Jan 5 20:31:56 2009 UTC
Added files: (Branch: PHP_5_3)
/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-20090105203156.txt
(text/plain, 14.4 KB)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute.c?r1=1.716.2.12.2.24.2.37&r2=1.716.2.12.2.24.2.38&diff_format=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.716.2.12.2.24.2.37 ZendEngine2/zend_execute.c:1.716.2.12.2.24.2.38
--- ZendEngine2/zend_execute.c:1.716.2.12.2.24.2.37 Wed Dec 31 11:15:32 2008
+++ ZendEngine2/zend_execute.c Mon Jan 5 20:31:51 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.716.2.12.2.24.2.37 2008/12/31 11:15:32 sebastian Exp $ */
+/* $Id: zend_execute.c,v 1.716.2.12.2.24.2.38 2009/01/05 20:31:51 felipe Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -837,10 +837,10 @@
}
}
break;
- case IS_DOUBLE:
- index = (long)Z_DVAL_P(dim);
+ case IS_DOUBLE: {
+ DVAL_TO_LVAL(Z_DVAL_P(dim), index);
goto num_index;
-
+ }
case IS_RESOURCE:
zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_LVAL_P(dim), Z_LVAL_P(dim));
/* Fall Through */
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_operators.c?r1=1.208.2.4.2.23.2.17&r2=1.208.2.4.2.23.2.18&diff_format=u
Index: ZendEngine2/zend_operators.c
diff -u ZendEngine2/zend_operators.c:1.208.2.4.2.23.2.17 ZendEngine2/zend_operators.c:1.208.2.4.2.23.2.18
--- ZendEngine2/zend_operators.c:1.208.2.4.2.23.2.17 Wed Dec 31 11:15:32 2008
+++ ZendEngine2/zend_operators.c Mon Jan 5 20:31:51 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.c,v 1.208.2.4.2.23.2.17 2008/12/31 11:15:32 sebastian Exp $ */
+/* $Id: zend_operators.c,v 1.208.2.4.2.23.2.18 2009/01/05 20:31:51 felipe Exp $ */
#include <ctype.h>
@@ -211,40 +211,6 @@
} \
}
-#define MAX_UNSIGNED_INT ((double) LONG_MAX * 2) + 1
-#ifdef _WIN64
-# define DVAL_TO_LVAL(d, l) \
- if ((d) > LONG_MAX) { \
- (l) = (long)(unsigned long)(__int64) (d); \
- } else { \
- (l) = (long) (d); \
- }
-#elif !defined(_WIN64) && __WORDSIZE == 64
-# define DVAL_TO_LVAL(d, l) \
- if ((d) >= LONG_MAX) { \
- (l) = LONG_MAX; \
- } else if ((d) <= LONG_MIN) { \
- (l) = LONG_MIN; \
- } else {\
- (l) = (long) (d); \
- }
-#else
-# define DVAL_TO_LVAL(d, l) \
- if ((d) > LONG_MAX) { \
- if ((d) > MAX_UNSIGNED_INT) { \
- (l) = LONG_MAX; \
- } else { \
- (l) = (unsigned long) (d); \
- } \
- } else { \
- if((d) < LONG_MIN) { \
- (l) = LONG_MIN; \
- } else { \
- (l) = (long) (d); \
- } \
- }
-#endif
-
#define zendi_convert_to_long(op, holder, result) \
if (op == result) { \
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_operators.h?r1=1.94.2.4.2.10.2.12&r2=1.94.2.4.2.10.2.13&diff_format=u
Index: ZendEngine2/zend_operators.h
diff -u ZendEngine2/zend_operators.h:1.94.2.4.2.10.2.12 ZendEngine2/zend_operators.h:1.94.2.4.2.10.2.13
--- ZendEngine2/zend_operators.h:1.94.2.4.2.10.2.12 Wed Dec 31 11:15:32 2008
+++ ZendEngine2/zend_operators.h Mon Jan 5 20:31:51 2009
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.h,v 1.94.2.4.2.10.2.12 2008/12/31 11:15:32 sebastian Exp $ */
+/* $Id: zend_operators.h,v 1.94.2.4.2.10.2.13 2009/01/05 20:31:51 felipe Exp $ */
#ifndef ZEND_OPERATORS_H
#define ZEND_OPERATORS_H
@@ -75,6 +75,40 @@
ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce TSRMLS_DC);
END_EXTERN_C()
+#define MAX_UNSIGNED_INT ((double) LONG_MAX * 2) + 1
+#ifdef _WIN64
+# define DVAL_TO_LVAL(d, l) \
+ if ((d) > LONG_MAX) { \
+ (l) = (long)(unsigned long)(__int64) (d); \
+ } else { \
+ (l) = (long) (d); \
+ }
+#elif !defined(_WIN64) && __WORDSIZE == 64
+# define DVAL_TO_LVAL(d, l) \
+ if ((d) >= LONG_MAX) { \
+ (l) = LONG_MAX; \
+ } else if ((d) <= LONG_MIN) { \
+ (l) = LONG_MIN; \
+ } else {\
+ (l) = (long) (d); \
+ }
+#else
+# define DVAL_TO_LVAL(d, l) \
+ if ((d) > LONG_MAX) { \
+ if ((d) > MAX_UNSIGNED_INT) { \
+ (l) = LONG_MAX; \
+ } else { \
+ (l) = (unsigned long) (d); \
+ } \
+ } else { \
+ if((d) < LONG_MIN) { \
+ (l) = LONG_MIN; \
+ } 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.48.2.79&r2=1.59.2.29.2.48.2.80&diff_format=u
Index: ZendEngine2/zend_vm_def.h
diff -u ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.79 ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.80
--- ZendEngine2/zend_vm_def.h:1.59.2.29.2.48.2.79 Thu Jan 1 15:28:15 2009
+++ ZendEngine2/zend_vm_def.h Mon Jan 5 20:31:51 2009
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_vm_def.h,v 1.59.2.29.2.48.2.79 2009/01/01 15:28:15 helly Exp $ */
+/* $Id: zend_vm_def.h,v 1.59.2.29.2.48.2.80 2009/01/05 20:31:51 felipe Exp $ */
/* If you change this file, please regenerate the zend_vm_execute.h and
* zend_vm_opcodes.h files by running:
@@ -3065,9 +3065,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.49.2.79&r2=1.62.2.30.2.49.2.80&diff_format=u
Index: ZendEngine2/zend_vm_execute.h
diff -u ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.79 ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.80
--- ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.79 Thu Jan 1 15:28:15 2009
+++ ZendEngine2/zend_vm_execute.h Mon Jan 5 20:31:51 2009
@@ -2820,9 +2820,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:
@@ -3338,9 +3340,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:
@@ -3807,9 +3811,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:
@@ -4000,9 +4006,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:
@@ -4468,9 +4476,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:
@@ -6015,9 +6025,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:
@@ -6481,9 +6493,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:
@@ -6947,9 +6961,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:
@@ -7040,9 +7056,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:
@@ -7503,9 +7521,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:
@@ -10511,9 +10531,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:
@@ -12287,9 +12309,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:
@@ -14114,9 +14138,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:
@@ -15002,9 +15028,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:
@@ -16547,9 +16575,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:
@@ -24198,9 +24228,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:
@@ -25862,9 +25894,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:
@@ -27576,9 +27610,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:
@@ -28358,9 +28394,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:
@@ -29794,9 +29832,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)
}