From: Moriyoshi Koizumi Date: Wed, 30 Oct 2002 11:42:51 +0000 (+0000) Subject: Fixed bug #20169 X-Git-Tag: php-4.3.0RC1~420 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ff7d5ff5437bb9a4a9e9d2682e0a48b6d621e49;p=php Fixed bug #20169 --- diff --git a/ext/standard/string.c b/ext/standard/string.c index b7e42c819c..3be7d77b7b 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -848,6 +848,7 @@ PHP_FUNCTION(implode) { zval **arg1 = NULL, **arg2 = NULL, *delim, *arr; int argc = ZEND_NUM_ARGS(); + int arg1_separated = 0, arg2_separated = 0, delim_needs_dtor = 0; if (argc < 1 || argc > 2 || zend_get_parameters_ex(argc, &arg1, &arg2) == FAILURE) { @@ -865,15 +866,19 @@ PHP_FUNCTION(implode) ZVAL_STRINGL(delim, _IMPL_EMPTY, sizeof(_IMPL_EMPTY) - 1, 0); SEPARATE_ZVAL(arg1); + arg1_separated = 1; + delim_needs_dtor = 1; arr = *arg1; } else { if (Z_TYPE_PP(arg1) == IS_ARRAY) { SEPARATE_ZVAL(arg1); + arg1_separated = 1; arr = *arg1; convert_to_string_ex(arg2); delim = *arg2; } else if (Z_TYPE_PP(arg2) == IS_ARRAY) { SEPARATE_ZVAL(arg2); + arg2_separated = 1; arr = *arg2; convert_to_string_ex(arg1); delim = *arg1; @@ -884,12 +889,9 @@ PHP_FUNCTION(implode) } php_implode(delim, arr, return_value); - zval_ptr_dtor(arg1); - if (arg2) { - zval_ptr_dtor(arg2); - } else { - FREE_ZVAL(delim); - } + if (arg1 != NULL && arg1_separated) zval_ptr_dtor(arg1); + if (arg2 != NULL && arg2_separated) zval_ptr_dtor(arg2); + if (delim_needs_dtor) FREE_ZVAL(delim); } /* }}} */