stas Fri Mar 16 20:16:05 2007 UTC Modified files: /php-src/ext/standard array.c /php-src/ext/standard/tests/array array_user_key_compare.phpt Log: Fix UMR in array_user_key_compare() (MOPB24 by Stefan Esser) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.404&r2=1.405&diff_format=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.404 php-src/ext/standard/array.c:1.405 --- php-src/ext/standard/array.c:1.404 Mon Jan 22 08:16:36 2007 +++ php-src/ext/standard/array.c Fri Mar 16 20:16:05 2007 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.404 2007/01/22 08:16:36 tony2001 Exp $ */ +/* $Id: array.c,v 1.405 2007/03/16 20:16:05 stas Exp $ */ #include "php.h" #include "php_ini.h" @@ -692,43 +692,42 @@ { Bucket *f; Bucket *s; - zval key1, key2; - zval *key1_ptr = &key1, *key2_ptr = &key2; + zval *key1, *key2; zval **args[2]; zval *retval_ptr = NULL; long result; - args[0] = &key1_ptr; - args[1] = &key2_ptr; - INIT_PZVAL(&key1); - INIT_PZVAL(&key2); + ALLOC_INIT_ZVAL(key1); + ALLOC_INIT_ZVAL(key2); + args[0] = &key1; + args[1] = &key2; f = *((Bucket **) a); s = *((Bucket **) b); if (f->nKeyLength == 0) { - Z_LVAL(key1) = f->h; - Z_TYPE(key1) = IS_LONG; + Z_LVAL_P(key1) = f->h; + Z_TYPE_P(key1) = IS_LONG; } else if (f->key.type == IS_UNICODE) { - Z_USTRVAL(key1) = eustrndup(f->key.arKey.u, f->nKeyLength-1); - Z_USTRLEN(key1) = f->nKeyLength-1; - Z_TYPE(key1) = IS_UNICODE; + Z_USTRVAL_P(key1) = eustrndup(f->key.arKey.u, f->nKeyLength-1); + Z_USTRLEN_P(key1) = f->nKeyLength-1; + Z_TYPE_P(key1) = IS_UNICODE; } else { - Z_STRVAL(key1) = estrndup(f->key.arKey.s, f->nKeyLength-1); - Z_STRLEN(key1) = f->nKeyLength-1; - Z_TYPE(key1) = f->key.type; + Z_STRVAL_P(key1) = estrndup(f->key.arKey.s, f->nKeyLength-1); + Z_STRLEN_P(key1) = f->nKeyLength-1; + Z_TYPE_P(key1) = f->key.type; } if (s->nKeyLength == 0) { - Z_LVAL(key2) = s->h; - Z_TYPE(key2) = IS_LONG; + Z_LVAL_P(key2) = s->h; + Z_TYPE_P(key2) = IS_LONG; } else if (s->key.type == IS_UNICODE) { - Z_USTRVAL(key2) = eustrndup(s->key.arKey.u, s->nKeyLength-1); - Z_USTRLEN(key2) = s->nKeyLength-1; - Z_TYPE(key2) = IS_UNICODE; + Z_USTRVAL_P(key2) = eustrndup(s->key.arKey.u, s->nKeyLength-1); + Z_USTRLEN_P(key2) = s->nKeyLength-1; + Z_TYPE_P(key2) = IS_UNICODE; } else { - Z_STRVAL(key2) = estrndup(s->key.arKey.s, s->nKeyLength-1); - Z_STRLEN(key2) = s->nKeyLength-1; - Z_TYPE(key2) = s->key.type; + Z_STRVAL_P(key2) = estrndup(s->key.arKey.s, s->nKeyLength-1); + Z_STRLEN_P(key2) = s->nKeyLength-1; + Z_TYPE_P(key2) = s->key.type; } BG(user_compare_fci).param_count = 2; @@ -745,12 +744,13 @@ result = 0; } - zval_dtor(&key1); - zval_dtor(&key2); + zval_ptr_dtor(&key1); + zval_ptr_dtor(&key2); return result; } + /* {{{ proto bool uksort(array array_arg, mixed comparator) U Sort an array by keys using a user-defined comparison function */ PHP_FUNCTION(uksort) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_user_key_compare.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/array_user_key_compare.phpt diff -u /dev/null php-src/ext/standard/tests/array/array_user_key_compare.phpt:1.2 --- /dev/null Fri Mar 16 20:16:05 2007 +++ php-src/ext/standard/tests/array/array_user_key_compare.phpt Fri Mar 16 20:16:05 2007 @@ -0,0 +1,19 @@ +--TEST-- +Fix UMR in array_user_key_compare (MOPB24) +--FILE-- +<?php +$arr = array("A" => 1, "B" => 1); + +function array_compare(&$key1, &$key2) + { + $GLOBALS['a'] = &$key2; + unset($key2); + return 1; + } + +uksort($arr, "array_compare"); +var_dump($a); + +?> +--EXPECTF-- +string(1) "A"
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php