Skip to content

Commit 65c7891

Browse files
committed
PHP array cannot refer to EG(symbol_table) any more. Replace corresponding checks by ZEND_ASSERT().
2 parents 91eb9a1 + 9fc1176 commit 65c7891

File tree

3 files changed

+20
-52
lines changed

3 files changed

+20
-52
lines changed

Zend/zend_gc.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,8 @@ static void gc_scan_black(zend_refcounted *ref, gc_stack *stack)
740740
goto next;
741741
}
742742
} else if (GC_TYPE(ref) == IS_ARRAY) {
743-
if ((zend_array*)ref != &EG(symbol_table)) {
744-
ht = (zend_array*)ref;
745-
} else {
746-
goto next;
747-
}
743+
ZEND_ASSERT((zend_array*)ref != &EG(symbol_table));
744+
ht = (zend_array*)ref;
748745
} else if (GC_TYPE(ref) == IS_REFERENCE) {
749746
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
750747
ref = Z_COUNTED(((zend_reference*)ref)->val);
@@ -861,12 +858,8 @@ static void gc_mark_grey(zend_refcounted *ref, gc_stack *stack)
861858
goto next;
862859
}
863860
} else if (GC_TYPE(ref) == IS_ARRAY) {
864-
if (((zend_array*)ref) == &EG(symbol_table)) {
865-
GC_REF_SET_BLACK(ref);
866-
goto next;
867-
} else {
868-
ht = (zend_array*)ref;
869-
}
861+
ZEND_ASSERT(((zend_array*)ref) != &EG(symbol_table));
862+
ht = (zend_array*)ref;
870863
} else if (GC_TYPE(ref) == IS_REFERENCE) {
871864
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
872865
ref = Z_COUNTED(((zend_reference*)ref)->val);
@@ -1046,12 +1039,8 @@ static void gc_scan(zend_refcounted *ref, gc_stack *stack)
10461039
goto next;
10471040
}
10481041
} else if (GC_TYPE(ref) == IS_ARRAY) {
1049-
if ((zend_array*)ref == &EG(symbol_table)) {
1050-
GC_REF_SET_BLACK(ref);
1051-
goto next;
1052-
} else {
1053-
ht = (zend_array*)ref;
1054-
}
1042+
ZEND_ASSERT((zend_array*)ref != &EG(symbol_table));
1043+
ht = (zend_array*)ref;
10551044
} else if (GC_TYPE(ref) == IS_REFERENCE) {
10561045
if (Z_REFCOUNTED(((zend_reference*)ref)->val)) {
10571046
ref = Z_COUNTED(((zend_reference*)ref)->val);

Zend/zend_vm_def.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6374,11 +6374,8 @@ ZEND_VM_C_LABEL(offset_again):
63746374
}
63756375
}
63766376
ZEND_VM_C_LABEL(str_index_dim):
6377-
if (ht == &EG(symbol_table)) {
6378-
zend_delete_global_variable(key);
6379-
} else {
6380-
zend_hash_del(ht, key);
6381-
}
6377+
ZEND_ASSERT(ht != &EG(symbol_table));
6378+
zend_hash_del(ht, key);
63826379
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
63836380
hval = Z_LVAL_P(offset);
63846381
ZEND_VM_C_LABEL(num_index_dim):

Zend/zend_vm_execute.h

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24360,11 +24360,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDL
2436024360
}
2436124361
}
2436224362
str_index_dim:
24363-
if (ht == &EG(symbol_table)) {
24364-
zend_delete_global_variable(key);
24365-
} else {
24366-
zend_hash_del(ht, key);
24367-
}
24363+
ZEND_ASSERT(ht != &EG(symbol_table));
24364+
zend_hash_del(ht, key);
2436824365
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
2436924366
hval = Z_LVAL_P(offset);
2437024367
num_index_dim:
@@ -26513,11 +26510,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMPVAR_HAND
2651326510
}
2651426511
}
2651526512
str_index_dim:
26516-
if (ht == &EG(symbol_table)) {
26517-
zend_delete_global_variable(key);
26518-
} else {
26519-
zend_hash_del(ht, key);
26520-
}
26513+
ZEND_ASSERT(ht != &EG(symbol_table));
26514+
zend_hash_del(ht, key);
2652126515
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
2652226516
hval = Z_LVAL_P(offset);
2652326517
num_index_dim:
@@ -30527,11 +30521,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER(
3052730521
}
3052830522
}
3052930523
str_index_dim:
30530-
if (ht == &EG(symbol_table)) {
30531-
zend_delete_global_variable(key);
30532-
} else {
30533-
zend_hash_del(ht, key);
30534-
}
30524+
ZEND_ASSERT(ht != &EG(symbol_table));
30525+
zend_hash_del(ht, key);
3053530526
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
3053630527
hval = Z_LVAL_P(offset);
3053730528
num_index_dim:
@@ -41794,11 +41785,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLE
4179441785
}
4179541786
}
4179641787
str_index_dim:
41797-
if (ht == &EG(symbol_table)) {
41798-
zend_delete_global_variable(key);
41799-
} else {
41800-
zend_hash_del(ht, key);
41801-
}
41788+
ZEND_ASSERT(ht != &EG(symbol_table));
41789+
zend_hash_del(ht, key);
4180241790
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
4180341791
hval = Z_LVAL_P(offset);
4180441792
num_index_dim:
@@ -45240,11 +45228,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMPVAR_HANDL
4524045228
}
4524145229
}
4524245230
str_index_dim:
45243-
if (ht == &EG(symbol_table)) {
45244-
zend_delete_global_variable(key);
45245-
} else {
45246-
zend_hash_del(ht, key);
45247-
}
45231+
ZEND_ASSERT(ht != &EG(symbol_table));
45232+
zend_hash_del(ht, key);
4524845233
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
4524945234
hval = Z_LVAL_P(offset);
4525045235
num_index_dim:
@@ -50365,11 +50350,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(Z
5036550350
}
5036650351
}
5036750352
str_index_dim:
50368-
if (ht == &EG(symbol_table)) {
50369-
zend_delete_global_variable(key);
50370-
} else {
50371-
zend_hash_del(ht, key);
50372-
}
50353+
ZEND_ASSERT(ht != &EG(symbol_table));
50354+
zend_hash_del(ht, key);
5037350355
} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
5037450356
hval = Z_LVAL_P(offset);
5037550357
num_index_dim:

0 commit comments

Comments
 (0)