From: Etienne Kneuss Date: Sat, 19 Jul 2008 13:13:44 +0000 (+0000) Subject: Fix valgrind errors in array_method, and possibly #45349 (Thanks tony for the patch) X-Git-Tag: BEFORE_HEAD_NS_CHANGE~1208 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0623e09d09e66998f99528d2450a7eb3afb9045;p=php Fix valgrind errors in array_method, and possibly #45349 (Thanks tony for the patch) --- diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 796ac5c4b9..b801aca3a1 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1235,11 +1235,11 @@ static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fnam { spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC); HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); - zval tmp, *arg; + zval *tmp, *arg; - INIT_PZVAL(&tmp); - Z_TYPE(tmp) = IS_ARRAY; - Z_ARRVAL(tmp) = aht; + MAKE_STD_ZVAL(tmp); + Z_TYPE_P(tmp) = IS_ARRAY; + Z_ARRVAL_P(tmp) = aht; if (use_arg) { if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) { @@ -1247,11 +1247,13 @@ static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fnam return; } zval_ptr_dtor(return_value_ptr); - zend_call_method(NULL, NULL, NULL, fname, fname_len, return_value_ptr, 2, &tmp, arg TSRMLS_CC); + zend_call_method(NULL, NULL, NULL, fname, fname_len, return_value_ptr, 2, tmp, arg TSRMLS_CC); } else { zval_ptr_dtor(return_value_ptr); - zend_call_method(NULL, NULL, NULL, fname, fname_len, return_value_ptr, 1, &tmp, NULL TSRMLS_CC); + zend_call_method(NULL, NULL, NULL, fname, fname_len, return_value_ptr, 1, tmp, NULL TSRMLS_CC); } + Z_TYPE_P(tmp) = IS_NULL; /* we want to destroy the zval, not the hashtable */ + zval_ptr_dtor(&tmp); } /* }}} */ /* {{{ SPL_ARRAY_METHOD */