From: Andi Gutmans Date: Fri, 9 Jun 2000 13:07:26 +0000 (+0000) Subject: - Make unset consistent with the way array offsets work X-Git-Tag: PRE_EIGHT_BYTE_ALLOC_PATCH~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a712da5cee5e512d13388cb74e53373d678b61e5;p=php - Make unset consistent with the way array offsets work --- diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 77b1ac6fd3..ebec3c0e99 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -2159,16 +2159,31 @@ send_by_ref: ht = NULL; break; } - if (ht) { + if (ht) { switch (offset->type) { + case IS_DOUBLE: + case IS_RESOURCE: + case IS_BOOL: case IS_LONG: - zend_hash_index_del(ht, offset->value.lval); + { + long index; + + if (offset->type == IS_DOUBLE) { + index = (long) offset->value.lval; + } else { + index = offset->value.lval; + } + zend_hash_index_del(ht, index); + break; + } + case IS_STRING: + zend_hash_del(ht, offset->value.str.val, offset->value.str.len+1); break; case IS_NULL: - zend_hash_del(ht,"",1); + zend_hash_del(ht, "", sizeof("")); break; - case IS_STRING: - zend_hash_del(ht, offset->value.str.val, offset->value.str.len+1); + default: + zend_error(E_WARNING, "Illegal offset type in unset"); break; } }