summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_mbregex.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
-rw-r--r--ext/mbstring/php_mbregex.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index 488a999b8f..0869f51c40 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -507,7 +507,7 @@ _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, int option)
}
if (err >= 0) {
#if moriyoshi_0
- if ( regs.beg[0] == regs.end[0] ) {
+ if (regs.beg[0] == regs.end[0]) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty regular expression");
break;
}
@@ -552,16 +552,15 @@ _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, int option)
if (pos < n) {
pos = n;
} else {
- _php_mb_regex_strbuf_ncat(&outdev, (const unsigned char *)&string[pos], 1 );
+ if (pos < string_len) {
+ _php_mb_regex_strbuf_ncat(&outdev, (const unsigned char *)&string[pos], 1);
+ }
pos++;
}
} else { /* nomatch */
/* stick that last bit of string on our output */
- int l = string_len - pos;
- if (l > 0) {
- _php_mb_regex_strbuf_ncat(&outdev, (const unsigned char *)&string[pos], l);
- } else {
- outdev.pos += l;
+ if (pos < string_len) {
+ _php_mb_regex_strbuf_ncat(&outdev, (const unsigned char *)&string[pos], string_len - pos);
}
}
}