]> granicus.if.org Git - php/commitdiff
- Fix for floating point array offsets. Same behaviour as in PHP 3.0. We
authorAndi Gutmans <andi@php.net>
Wed, 8 Sep 1999 20:38:08 +0000 (20:38 +0000)
committerAndi Gutmans <andi@php.net>
Wed, 8 Sep 1999 20:38:08 +0000 (20:38 +0000)
  casted to (long).

Zend/zend_execute.c

index d4696ccd94457e8e0769493628368f45985f5820..bbfbe6645535596dd91e3205eaca029527024e2c 100644 (file)
@@ -530,33 +530,37 @@ static inline zval **zend_fetch_dimension_address_inner(HashTable *ht, znode *op
                                }
                        }
                        break;
+               case IS_DOUBLE:
                case IS_LONG: {
-                               if (zend_hash_index_find(ht, dim->value.lval, (void **) &retval) == FAILURE) {
+                               long index;
+
+                               if(dim->type == IS_LONG) {
+                                       index = dim->value.lval;
+                               } else {
+                                       index = (long)dim->value.dval;
+                               }
+                               if (zend_hash_index_find(ht, index, (void **) &retval) == FAILURE) {
                                        switch (type) {
                                                case BP_VAR_R: 
-                                                       zend_error(E_NOTICE,"Undefined offset:  %d", dim->value.lval);
+                                                       zend_error(E_NOTICE,"Undefined offset:  %d", index);
                                                        /* break missing intentionally */
                                                case BP_VAR_IS:
                                                        retval = &EG(uninitialized_zval_ptr);
                                                        break;
                                                case BP_VAR_RW:
-                                                       zend_error(E_NOTICE,"Undefined offset:  %d", dim->value.lval);
+                                                       zend_error(E_NOTICE,"Undefined offset:  %d", index);
                                                        /* break missing intentionally */
                                                case BP_VAR_W: {
                                                                zval *new_zval = &EG(uninitialized_zval);
 
                                                                new_zval->refcount++;
-                                                               zend_hash_index_update(ht, dim->value.lval, &new_zval, sizeof(zval *), (void **) &retval);
+                                                               zend_hash_index_update(ht, index, &new_zval, sizeof(zval *), (void **) &retval);
                                                        }
                                                        break;
                                        }
                                }
                        }
                        break;
-               /* we need to do implement this nicely somehow ZA
-               case IS_DOUBLE:
-                       break;
-               */
                default: 
                        zend_error(E_WARNING, "Illegal offset type");
                        if (type == BP_VAR_R || type == BP_VAR_IS) {