From: Brad LaFountain Date: Thu, 1 Aug 2002 17:34:31 +0000 (+0000) Subject: array_pop wasnt setting next index X-Git-Tag: dev~59 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b0553c390cb052c0518eaf81cc5149e261dd171;p=php array_pop wasnt setting next index --- diff --git a/ext/standard/array.c b/ext/standard/array.c index 9d01b233ae..4f2dbf12c8 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1663,7 +1663,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end) zval **stack, /* Input stack */ **val; /* Value to be popped */ char *key = NULL; - int key_len; + int key_len = 0; ulong index; /* Get the arguments and do error-checking */ @@ -1696,19 +1696,16 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end) /* If we did a shift... re-index like it did before */ if (!off_the_end) { - HANDLE_BLOCK_INTERRUPTIONS(); - { - int k = 0; - Bucket *p = Z_ARRVAL_PP(stack)->pListHead; - while (p != NULL) { - if (p->nKeyLength == 0) - p->h = k++; - p = p->pListNext; - } - Z_ARRVAL_PP(stack)->nNextFreeElement = k+1; - zend_hash_rehash(Z_ARRVAL_PP(stack)); + int k = 0; + Bucket *p = Z_ARRVAL_PP(stack)->pListHead; + while (p != NULL) { + if (p->nKeyLength == 0) + p->h = k++; + p = p->pListNext; } - HANDLE_UNBLOCK_INTERRUPTIONS(); + Z_ARRVAL_PP(stack)->nNextFreeElement = k+1; + } else if(!key_len) { + Z_ARRVAL_PP(stack)->nNextFreeElement = Z_ARRVAL_PP(stack)->nNextFreeElement - 1; } } /* }}} */