]> granicus.if.org Git - php/commitdiff
MFH: fix DVAL_TO_LVAL conversion for static array indexes, related to bug #46701
authorBrian Shire <shire@php.net>
Wed, 22 Apr 2009 21:27:19 +0000 (21:27 +0000)
committerBrian Shire <shire@php.net>
Wed, 22 Apr 2009 21:27:19 +0000 (21:27 +0000)
Zend/zend_compile.c

index bee07b77a48f5b2b53e21210fd796d672abce878..dfe8595b907c7b1c3862588ba5a2dfb073c254c2 100644 (file)
@@ -3997,6 +3997,7 @@ void zend_do_add_static_array_element(znode *result, znode *offset, const znode
        ALLOC_ZVAL(element);
        *element = expr->u.constant;
        if (offset) {
+               long l;
                switch (offset->u.constant.type & IS_CONSTANT_TYPE_MASK) {
                        case IS_CONSTANT:
                                /* Ugly hack to denote that this value has a constant index */
@@ -4019,7 +4020,8 @@ void zend_do_add_static_array_element(znode *result, znode *offset, const znode
                                zend_hash_index_update(Z_ARRVAL(result->u.constant), Z_LVAL(offset->u.constant), &element, sizeof(zval *), NULL);
                                break;
                        case IS_DOUBLE:
-                               zend_hash_index_update(Z_ARRVAL(result->u.constant), (long)Z_DVAL(offset->u.constant), &element, sizeof(zval *), NULL);
+                               DVAL_TO_LVAL(Z_DVAL(offset->u.constant), l);
+                               zend_hash_index_update(Z_ARRVAL(result->u.constant), l, &element, sizeof(zval *), NULL);
                                break;
                        case IS_CONSTANT_ARRAY:
                                zend_error(E_ERROR, "Illegal offset type");