summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_mbregex.c
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2014-03-24 12:37:05 +0800
committerXinchen Hui <laruence@gmail.com>2014-03-24 12:40:07 +0800
commit506f6a428267379b4aceb91d3a66d0762f3fd3a3 (patch)
treea0ff00e6efd901b63c84e2616db6c445da582365 /ext/mbstring/php_mbregex.c
parent9011a70c7f83ce5fc70ac9b6aef523ddda9e84fa (diff)
downloadphp-git-506f6a428267379b4aceb91d3a66d0762f3fd3a3.tar.gz
Refactor mbstring (incompleted)
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
-rw-r--r--ext/mbstring/php_mbregex.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index 8d84e41054..e9307df5d7 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -740,9 +740,11 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
match_len = 1;
str = string;
if (array != NULL) {
- match_len = regs->end[0] - regs->beg[0];
+ ZVAL_DEREF(array);
zval_dtor(array);
array_init(array);
+
+ match_len = regs->end[0] - regs->beg[0];
for (i = 0; i < regs->num_regs; i++) {
beg = regs->beg[i];
end = regs->end[i];
@@ -1011,9 +1013,11 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp
if (err <= -2) {
smart_str_free(&out_buf);
RETVAL_FALSE;
- } else {
- smart_str_appendc(&out_buf, '\0');
+ } else if (out_buf.s) {
+ smart_str_0(&out_buf);
RETVAL_STR(out_buf.s);
+ } else {
+ RETVAL_EMPTY_STRING();
}
}
/* }}} */