diff options
-rw-r--r-- | ext/mbstring/php_mbregex.c | 3 | ||||
-rw-r--r-- | ext/mbstring/tests/bug77514.phpt | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index d443999f74..eb3cf3c686 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -713,8 +713,7 @@ static inline void mb_regex_substitute( sp = p; /* save position */ clen = (int) php_mb_mbchar_bytes_ex(++p, enc); if (clen != 1 || p == eos) { - /* skip escaped multibyte char */ - p += clen; + /* skip backslash followed by multibyte char */ smart_str_appendl(pbuf, sp, p - sp); continue; } diff --git a/ext/mbstring/tests/bug77514.phpt b/ext/mbstring/tests/bug77514.phpt new file mode 100644 index 0000000000..efcbea24d7 --- /dev/null +++ b/ext/mbstring/tests/bug77514.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #77514: mb_ereg_replace() with trailing backslash adds null byte +--FILE-- +<?php + +$a="abc123"; +var_dump(mb_ereg_replace("123","def\\",$a)); + +?> +--EXPECT-- +string(7) "abcdef\" |