From: Moriyoshi Koizumi Date: Fri, 26 Sep 2003 17:47:10 +0000 (+0000) Subject: MFH(r-1.45): repatch fixes for the problem that was reported at php-dev@php.gr.jp... X-Git-Tag: php-4.3.4RC1~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18557cba09ebf1cecee140348dae6d1b14d47c3a;p=php MFH(r-1.45): repatch fixes for the problem that was reported at php-dev@php.gr.jp (#884) --- 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); } } }