com php-src: Fixed bug #68644 (strlen incorrect : mbstring + func_overload=2 +UTF-8 + Opcache): NEWS e xt/opcache/Optimizer/pass1_5.c
ext/opcache/tests/bug 68644.phpt
| From: | Xinchen Hui | Date: | Wed, 24 Dec 2014 09:55:58 +0000 |
| Subject: | com php-src: Fixed bug #68644 (strlen incorrect : mbstring + func_overload=2 +UTF-8 + Opcache): NEWS e xt/opcache/Optimizer/pass1_5.c ext/opcache/tests/bug 68644.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-83846@lists.php.net to get a copy of this message | ||
Commit: bba4a8aad52df652c95dfd1d7e2289d479b23b99
Author: Xinchen Hui <laruence@php.net> Wed, 24 Dec 2014 17:55:58 +0800
Parents: 87ccf50badc9926260b62ca466bdd515901815fd
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bba4a8aad52df652c95dfd1d7e2289d479b23b99
Log:
Fixed bug #68644 (strlen incorrect : mbstring + func_overload=2 +UTF-8 + Opcache)
Bugs:
https://bugs.php.net/68644
Changed paths:
M NEWS
M ext/opcache/Optimizer/pass1_5.c
A ext/opcache/tests/bug68644.phpt
Diff:
diff --git a/NEWS b/NEWS
index 12b6aac..6f62686 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,8 @@ PHP NEWS
(Ashesh Vashi)
- Opcache:
+ . Fixed bug #68644 (strlen incorrect : mbstring + func_overload=2 +UTF-8
+ + Opcache). (Laruence)
. Fixed bug #67111 (Memory leak when using "continue 2" inside two foreach
loops). (Nikita)
diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c
index 41dde05..731040e 100644
--- a/ext/opcache/Optimizer/pass1_5.c
+++ b/ext/opcache/Optimizer/pass1_5.c
@@ -450,9 +450,11 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
MAKE_NOP(opline);
}
}
- } else if (Z_STRLEN(ZEND_OP1_LITERAL(opline)) == sizeof("strlen")-1 &&
- !memcmp(Z_STRVAL(ZEND_OP1_LITERAL(opline)),
- "strlen", sizeof("strlen")-1)) {
+ } else if ((!zend_hash_exists(&module_registry, "mbstring",
sizeof("mbstring")) ||
+ zend_ini_long("mbstring.func_overload",
+ sizeof("mbstring.func_overload"), 0) < 2 /* MB_OVERLOAD_STRING */) &&
+ Z_STRLEN(ZEND_OP1_LITERAL(opline)) == sizeof("strlen") - 1 &&
+ !memcmp(Z_STRVAL(ZEND_OP1_LITERAL(opline)), "strlen", sizeof("strlen") -
1)) {
zval t;
ZVAL_LONG(&t, Z_STRLEN(ZEND_OP1_LITERAL(opline - 1)));
diff --git a/ext/opcache/tests/bug68644.phpt b/ext/opcache/tests/bug68644.phpt
new file mode 100644
index 0000000..2d3233f
--- /dev/null
+++ b/ext/opcache/tests/bug68644.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #68644 strlen incorrect : mbstring + func_overload=2 + UTF-8 + Opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+mbstring.func_overload=2
+mbstring.internal_encoding=UTF-8
+--SKIPIF--
+<?php if (!extension_loaded('Zend OPcache') ||
!extension_loaded("mbstring")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(strlen("中国, 北京"));
+var_dump(mb_strlen("中国, 北京"));
+?>
+--EXPECT--
+int(6)
+int(6)