]> granicus.if.org Git - php/commitdiff
MFH(r-1.45): repatch fixes for the problem that was reported at php-dev@php.gr.jp...
authorMoriyoshi Koizumi <moriyoshi@php.net>
Fri, 26 Sep 2003 17:47:10 +0000 (17:47 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Fri, 26 Sep 2003 17:47:10 +0000 (17:47 +0000)
ext/mbstring/php_mbregex.c

index 488a999b8f5a6f672fb1a5d74776273d71dd049b..0869f51c406f1d7e1cb8919583251a70d2302db7 100644 (file)
@@ -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);
                        }
                }
        }