]> granicus.if.org Git - php/commitdiff
Fixed bug #75729
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 5 Feb 2018 20:08:18 +0000 (21:08 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 5 Feb 2018 20:08:18 +0000 (21:08 +0100)
Don't try to evaluate substr() and strpos() at compile-time if
mbstring function overloading is enabled. I'm reusing the
COMPILE_NO_BUILTIN_STRLEN for the detection of mbstring function
overloading here, even if it's technically only about strlen()...

NEWS
ext/opcache/Optimizer/sccp.c
ext/opcache/tests/bug75729.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index fde430f53096bb4bb1fe9f5f5ff469afd8d20e16..29349901610499f2d27121d7acbabc480d8b3421 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,9 @@ PHP                                                                        NEWS
 - ODBC:
   . Fixed bug #73725 (Unable to retrieve value of varchar(max) type). (Anatol)
 
+- Opcache:
+  . Fixed bug #75729 (opcache segfault when installing Bitrix). (Nikita)
+
 - Standard:
   . Fixed bug #75916 (DNS_CAA record results contain garbage). (Mike,
     Philip Sharp)
index abb4664475fedae68fd5a95a22d47d18bc383574..c3c719c1bdd3ef55884470aee11cb330aeee128f 100644 (file)
@@ -695,7 +695,8 @@ static inline int ct_eval_func_call(
                } else if (zend_string_equals_literal(name, "strpos")) {
                        if (Z_TYPE_P(args[0]) != IS_STRING
                                        || Z_TYPE_P(args[1]) != IS_STRING
-                                       || !Z_STRLEN_P(args[1])) {
+                                       || !Z_STRLEN_P(args[1])
+                                       || (CG(compiler_options) & ZEND_COMPILE_NO_BUILTIN_STRLEN)) {
                                return FAILURE;
                        }
                        /* pass */
@@ -774,7 +775,8 @@ static inline int ct_eval_func_call(
                        /* pass */
                } else if (zend_string_equals_literal(name, "substr")) {
                        if (Z_TYPE_P(args[0]) != IS_STRING
-                                       || Z_TYPE_P(args[1]) != IS_LONG) {
+                                       || Z_TYPE_P(args[1]) != IS_LONG
+                                       || (CG(compiler_options) & ZEND_COMPILE_NO_BUILTIN_STRLEN)) {
                                return FAILURE;
                        }
                        /* pass */
diff --git a/ext/opcache/tests/bug75729.phpt b/ext/opcache/tests/bug75729.phpt
new file mode 100644 (file)
index 0000000..1bf2383
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #75729: opcache segfault when installing Bitrix
+--SKIPIF--
+<?php if (!extension_loaded('mbstring')) die('skip mbstring not loaded'); ?>
+--INI--
+opcache.enable_cli=1
+mbstring.func_overload=2
+--FILE--
+<?php
+
+var_dump(strpos("foo", "o"));
+
+?>
+--EXPECT--
+Deprecated: The mbstring.func_overload directive is deprecated in Unknown on line 0
+int(1)