}
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;
}
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);
}
}
}