From: Andrei Zmievski Date: Sun, 20 May 2001 01:21:44 +0000 (+0000) Subject: Properly free callback_name only when necessary. X-Git-Tag: PRE_GRANULAR_GARBAGE_FIX~333 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1f671fb5ca24467b5c9bc9b0d1b4f874459b652;p=php Properly free callback_name only when necessary. --- diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 4344591cd6..b380604507 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -981,16 +981,17 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_callabl SEPARATE_ZVAL(replace); if (Z_TYPE_PP(replace) != IS_ARRAY) convert_to_string_ex(replace); - if (is_callable_replace && !zend_is_callable(*replace, 0, &callback_name)) { - php_error(E_WARNING, "%s() requires argument 2, '%s', to be a valid callback", - get_active_function_name(), callback_name); + if (is_callable_replace) { + if (!zend_is_callable(*replace, 0, &callback_name)) { + php_error(E_WARNING, "%s() requires argument 2, '%s', to be a valid callback", + get_active_function_name(), callback_name); + efree(callback_name); + *return_value = **subject; + zval_copy_ctor(return_value); + return; + } efree(callback_name); - *return_value = **subject; - zval_copy_ctor(return_value); - return; } - if (callback_name) - efree(callback_name); SEPARATE_ZVAL(regex); SEPARATE_ZVAL(subject);