moriyoshi Fri Sep 26 13:43:39 2003 EDT
Modified files:
/php-src/ext/mbstring php_mbregex.c
Log:
Repatch fixes for the problem that was reported at [EMAIL PROTECTED] (#884)
Index: php-src/ext/mbstring/php_mbregex.c
diff -u php-src/ext/mbstring/php_mbregex.c:1.44 php-src/ext/mbstring/php_mbregex.c:1.45
--- php-src/ext/mbstring/php_mbregex.c:1.44 Tue Sep 23 16:11:05 2003
+++ php-src/ext/mbstring/php_mbregex.c Fri Sep 26 13:43:39 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mbregex.c,v 1.44 2003/09/23 20:11:05 moriyoshi Exp $ */
+/* $Id: php_mbregex.c,v 1.45 2003/09/26 17:43:39 moriyoshi Exp $ */
#ifdef HAVE_CONFIG_H
@@ -516,6 +516,7 @@
smart_str *pbuf;
int i, err, eval, n;
UChar *pos;
+ UChar *string_lim;
char *description = NULL;
char pat_buf[2];
@@ -579,9 +580,10 @@
/* do the actual work */
err = 0;
pos = string;
+ string_lim = (UChar*)(string + string_len);
regs = php_mb_regex_region_new();
while (err >= 0) {
- err = php_mb_regex_search(re, (UChar *)string, (UChar *)(string +
string_len), pos, (UChar *)(string + string_len), regs, 0);
+ err = php_mb_regex_search(re, (UChar *)string, (UChar *)string_lim,
pos, (UChar *)string_lim, regs, 0);
if (err <= -2) {
UChar err_str[REG_MAX_ERROR_MESSAGE_LEN];
php_mb_regex_error_code_to_str(err_str, err);
@@ -636,16 +638,15 @@
if ((size_t)(pos - (UChar *)string) < n) {
pos = string + n;
} else {
- smart_str_appendl(&out_buf, pos, 1);
+ if (pos < string_lim) {
+ smart_str_appendl(&out_buf, pos, 1);
+ }
pos++;
}
} else { /* nomatch */
/* stick that last bit of string on our output */
- int l = (UChar *)(string + string_len) - pos;
- if (l > 0) {
- smart_str_appendl(&out_buf, pos, l);
- } else {
- out_buf.len += l;
+ if (string_lim - pos > 0) {
+ smart_str_appendl(&out_buf, pos, string_lim - pos);
}
}
php_mb_regex_region_free(regs, 0);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php