summaryrefslogtreecommitdiff
path: root/ext/pcre/php_pcre.c
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2001-05-20 01:21:44 +0000
committerAndrei Zmievski <andrei@php.net>2001-05-20 01:21:44 +0000
commite1f671fb5ca24467b5c9bc9b0d1b4f874459b652 (patch)
tree89960e17b2059970ec329ed5bc9ce124e892fd21 /ext/pcre/php_pcre.c
parent45ebd79180db6b9d941857c5a927de9c3e46bf39 (diff)
downloadphp-git-e1f671fb5ca24467b5c9bc9b0d1b4f874459b652.tar.gz
Properly free callback_name only when necessary.
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r--ext/pcre/php_pcre.c17
1 files changed, 9 insertions, 8 deletions
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);