Skip to content

Commit cf68bc4

Browse files
committed
Fixed bug #79434
1 parent 14b770d commit cf68bc4

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.3.18
44

5+
- Core:
6+
. Fixed bug #79434 (PHP 7.3 and PHP-7.4 crash with NULL-pointer dereference
7+
on !CS constant). (Nikita)
8+
59
- MBString:
610
. Fixed bug #79441 (Segfault in mb_chr() if internal encoding is unsupported).
711
(Girgias)

Zend/tests/case_insensitive_constant_deprecation.phpt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace {
99

1010
var_dump(FOO); // Ok
1111
var_dump(foo); // Deprecated
12+
var_dump(\foo); // Deprecated
1213

1314
var_dump(NS\FOO); // Ok
1415
var_dump(ns\FOO); // Ok
@@ -72,10 +73,13 @@ int(42)
7273

7374
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 8
7475
int(42)
76+
77+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 9
78+
int(42)
7579
int(24)
7680
int(24)
7781

78-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 12
82+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 13
7983
int(24)
8084
bool(true)
8185
bool(true)
@@ -84,24 +88,24 @@ bool(true)
8488
bool(true)
8589
int(42)
8690

87-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 21
91+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 22
8892
int(42)
8993
int(24)
9094
int(24)
9195

92-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 24
96+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 25
9397
int(24)
9498
int(24)
9599

96-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 29
100+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 30
97101
int(24)
98102
int(24)
99103

100-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 34
104+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 35
101105
int(24)
102106
int(42)
103107

104-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 39
108+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 40
105109
int(42)
106110
bool(true)
107111
bool(true)
@@ -110,18 +114,18 @@ bool(true)
110114
bool(true)
111115
int(42)
112116

113-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 48
117+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 49
114118
int(42)
115119
int(24)
116120
int(24)
117121

118-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 51
122+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "NS\FOO" in %s on line 52
119123
int(24)
120124
int(42)
121125

122-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 55
126+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 56
123127
int(42)
124128
int(43)
125129

126-
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 59
130+
Deprecated: Case-insensitive constants are deprecated. The correct casing for this constant is "FOO" in %s on line 60
127131
int(43)

Zend/zend_execute.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,11 +3364,15 @@ static zend_always_inline int _zend_quick_get_constant(
33643364
is_deprecated = !zend_string_equals(c->name, Z_STR_P(access_key));
33653365
} else {
33663366
check_short_name:
3367-
ns_sep = zend_memrchr(ZSTR_VAL(c->name), '\\', ZSTR_LEN(c->name));
3368-
ZEND_ASSERT(ns_sep);
33693367
/* Namespaces are always case-insensitive. Only compare shortname. */
3370-
shortname_offset = ns_sep - ZSTR_VAL(c->name) + 1;
3371-
shortname_len = ZSTR_LEN(c->name) - shortname_offset;
3368+
ns_sep = zend_memrchr(ZSTR_VAL(c->name), '\\', ZSTR_LEN(c->name));
3369+
if (ns_sep) {
3370+
shortname_offset = ns_sep - ZSTR_VAL(c->name) + 1;
3371+
shortname_len = ZSTR_LEN(c->name) - shortname_offset;
3372+
} else {
3373+
shortname_offset = 0;
3374+
shortname_len = ZSTR_LEN(c->name);
3375+
}
33723376

33733377
is_deprecated = memcmp(ZSTR_VAL(c->name) + shortname_offset, Z_STRVAL_P(orig_key - 1) + shortname_offset, shortname_len) != 0;
33743378
}

0 commit comments

Comments
 (0)