diff options
author | Xinchen Hui <laruence@php.net> | 2014-12-24 17:55:58 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2014-12-24 17:55:58 +0800 |
commit | bba4a8aad52df652c95dfd1d7e2289d479b23b99 (patch) | |
tree | d8cee04b0ae8ac6da2a889fd6a435f1254612b28 | |
parent | 87ccf50badc9926260b62ca466bdd515901815fd (diff) | |
download | php-git-bba4a8aad52df652c95dfd1d7e2289d479b23b99.tar.gz |
Fixed bug #68644 (strlen incorrect : mbstring + func_overload=2 +UTF-8 + Opcache)
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | ext/opcache/Optimizer/pass1_5.c | 8 | ||||
-rw-r--r-- | ext/opcache/tests/bug68644.phpt | 17 |
3 files changed, 24 insertions, 3 deletions
@@ -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 41dde05083..731040e960 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 0000000000..2d3233f6bf --- /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) |