diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-04-02 16:32:57 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-04-02 16:34:03 +0200 |
commit | cf68bc413bd7548643058a63dbf4d907346d184c (patch) | |
tree | dc97f605afdcaac9a72c279c14786183f92868ab | |
parent | 14b770d4074616f7f5dcf026422a91a8b7419d90 (diff) | |
download | php-git-cf68bc413bd7548643058a63dbf4d907346d184c.tar.gz |
Fixed bug #79434
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | Zend/tests/case_insensitive_constant_deprecation.phpt | 24 | ||||
-rw-r--r-- | Zend/zend_execute.c | 12 |
3 files changed, 26 insertions, 14 deletions
@@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 7.3.18 +- Core: + . Fixed bug #79434 (PHP 7.3 and PHP-7.4 crash with NULL-pointer dereference + on !CS constant). (Nikita) + - MBString: . Fixed bug #79441 (Segfault in mb_chr() if internal encoding is unsupported). (Girgias) diff --git a/Zend/tests/case_insensitive_constant_deprecation.phpt b/Zend/tests/case_insensitive_constant_deprecation.phpt index e7a92c8c4c..6ab18b3763 100644 --- a/Zend/tests/case_insensitive_constant_deprecation.phpt +++ b/Zend/tests/case_insensitive_constant_deprecation.phpt @@ -9,6 +9,7 @@ namespace { var_dump(FOO); // Ok var_dump(foo); // Deprecated + var_dump(\foo); // Deprecated var_dump(NS\FOO); // Ok var_dump(ns\FOO); // Ok @@ -72,10 +73,13 @@ int(42) Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 8 int(42) + +Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 9 +int(42) int(24) int(24) -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 12 +Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 13 int(24) bool(true) bool(true) @@ -84,24 +88,24 @@ bool(true) bool(true) int(42) -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 21 +Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 22 int(42) int(24) int(24) -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 24 +Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 25 int(24) int(24) -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 29 +Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 30 int(24) int(24) -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 34 +Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 35 int(24) int(42) -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 39 +Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 40 int(42) bool(true) bool(true) @@ -110,18 +114,18 @@ bool(true) bool(true) int(42) -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 48 +Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 49 int(42) int(24) int(24) -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 51 +Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 52 int(24) int(42) -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 55 +Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 56 int(42) int(43) -Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 59 +Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 60 int(43) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 0a505f55e8..0eb6639b2e 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -3364,11 +3364,15 @@ static zend_always_inline int _zend_quick_get_constant( is_deprecated = !zend_string_equals(c->name, Z_STR_P(access_key)); } else { check_short_name: - ns_sep = zend_memrchr(ZSTR_VAL(c->name), '\\', ZSTR_LEN(c->name)); - ZEND_ASSERT(ns_sep); /* Namespaces are always case-insensitive. Only compare shortname. */ - shortname_offset = ns_sep - ZSTR_VAL(c->name) + 1; - shortname_len = ZSTR_LEN(c->name) - shortname_offset; + ns_sep = zend_memrchr(ZSTR_VAL(c->name), '\\', ZSTR_LEN(c->name)); + if (ns_sep) { + shortname_offset = ns_sep - ZSTR_VAL(c->name) + 1; + shortname_len = ZSTR_LEN(c->name) - shortname_offset; + } else { + shortname_offset = 0; + shortname_len = ZSTR_LEN(c->name); + } is_deprecated = memcmp(ZSTR_VAL(c->name) + shortname_offset, Z_STRVAL_P(orig_key - 1) + shortname_offset, shortname_len) != 0; } |