summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Hirokawa <hirokawa@php.net>2007-08-19 01:58:39 +0000
committerRui Hirokawa <hirokawa@php.net>2007-08-19 01:58:39 +0000
commit1d440544074fc92cd7886b66fb6ee51c88be023c (patch)
tree6f3d5e7f34bade3a63d638fc5827f4dbd40a15b6
parent1d48a1081c0b31f64c3ab72625b32a41fc5bacb1 (diff)
downloadphp-git-1d440544074fc92cd7886b66fb6ee51c88be023c.tar.gz
MFH (fixed #42085)
-rw-r--r--ext/mbstring/libmbfl/mbfl/mbfilter.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.c b/ext/mbstring/libmbfl/mbfl/mbfilter.c
index a8e3b68d33..97d2f048cc 100644
--- a/ext/mbstring/libmbfl/mbfl/mbfilter.c
+++ b/ext/mbstring/libmbfl/mbfl/mbfilter.c
@@ -858,7 +858,7 @@ mbfl_strpos(
int offset,
int reverse)
{
- int n, result;
+ int n, result, negative_offset = 0;
unsigned char *p;
mbfl_convert_filter *filter;
struct collector_strpos_data pc;
@@ -904,6 +904,12 @@ mbfl_strpos(
mbfl_wchar_device_clear(&pc.needle);
return -4;
}
+
+ if (offset < 0) {
+ negative_offset = -offset-1;
+ offset = 0;
+ }
+
pc.start = offset;
pc.output = 0;
pc.needle_pos = 0;
@@ -912,7 +918,7 @@ mbfl_strpos(
/* feed data */
p = haystack->val;
- n = haystack->len;
+ n = haystack->len - negative_offset;
if (p != NULL) {
while (n > 0) {
if ((*filter->filter_function)(*p++, filter) < 0) {