Skip to content

Commit 32bd339

Browse files
authored
Remove unreachable code after zend_error_noreturn calls (phpGH-20983)
1 parent ad0baf0 commit 32bd339

File tree

10 files changed

+0
-27
lines changed

10 files changed

+0
-27
lines changed

Zend/zend_API.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,8 +2430,6 @@ ZEND_API zend_result zend_startup_module_ex(zend_module_entry *module) /* {{{ */
24302430
EG(current_module) = module;
24312431
if (module->module_startup_func(module->type, module->module_number)==FAILURE) {
24322432
zend_error_noreturn(E_CORE_ERROR,"Unable to start %s module", module->name);
2433-
EG(current_module) = NULL;
2434-
return FAILURE;
24352433
}
24362434
EG(current_module) = NULL;
24372435
}

Zend/zend_alloc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,6 @@ static zend_always_inline void *zend_mm_alloc_heap(zend_mm_heap *heap, size_t si
14801480
size = ZEND_MM_ALIGNED_SIZE(size) + ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info));
14811481
if (UNEXPECTED(size < real_size)) {
14821482
zend_error_noreturn(E_ERROR, "Possible integer overflow in memory allocation (%zu + %zu)", ZEND_MM_ALIGNED_SIZE(real_size), ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info)));
1483-
return NULL;
14841483
}
14851484
#endif
14861485
if (EXPECTED(size <= ZEND_MM_MAX_SMALL_SIZE)) {

Zend/zend_compile.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,7 +2670,6 @@ static void zend_emit_return_type_check(
26702670
ZEND_ASSERT(!implicit);
26712671
zend_error_noreturn(E_COMPILE_ERROR, "A never-returning %s must not return",
26722672
CG(active_class_entry) != NULL ? "method" : "function");
2673-
return;
26742673
}
26752674

26762675
if (!expr && !implicit) {
@@ -7678,14 +7677,12 @@ static zend_type zend_compile_typename_ex(
76787677
zend_string *standard_type_str = zend_type_to_string(single_type);
76797678
zend_error_noreturn(E_COMPILE_ERROR,
76807679
"Type %s cannot be part of an intersection type", ZSTR_VAL(standard_type_str));
7681-
zend_string_release_ex(standard_type_str, false);
76827680
}
76837681
/* An intersection of standard types cannot exist so invalidate it */
76847682
if (ZEND_TYPE_IS_ONLY_MASK(single_type)) {
76857683
zend_string *standard_type_str = zend_type_to_string(single_type);
76867684
zend_error_noreturn(E_COMPILE_ERROR,
76877685
"Type %s cannot be part of an intersection type", ZSTR_VAL(standard_type_str));
7688-
zend_string_release_ex(standard_type_str, false);
76897686
}
76907687
/* Check for "self" and "parent" too */
76917688
if (
@@ -7918,7 +7915,6 @@ static void zend_compile_attributes(
79187915
if (error != NULL) {
79197916
if (delayed_target_validation == NULL) {
79207917
zend_error_noreturn(E_COMPILE_ERROR, "%s", ZSTR_VAL(error));
7921-
zend_string_efree(error);
79227918
} else {
79237919
attr->validation_error = error;
79247920
}
@@ -10483,7 +10479,6 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
1048310479
goto fail;
1048410480
default:
1048510481
zend_error_noreturn(E_COMPILE_ERROR, "Illegal offset type");
10486-
break;
1048710482
}
1048810483
} else if (!zend_hash_next_index_insert(Z_ARRVAL_P(result), value)) {
1048910484
fail:
@@ -11687,7 +11682,6 @@ static void zend_compile_const_expr_class_name(zend_ast **ast_ptr) /* {{{ */
1168711682
case ZEND_FETCH_CLASS_STATIC:
1168811683
zend_error_noreturn(E_COMPILE_ERROR,
1168911684
"static::class cannot be used for compile-time class name resolution");
11690-
return;
1169111685
EMPTY_SWITCH_DEFAULT_CASE()
1169211686
}
1169311687
}

Zend/zend_execute_API.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,6 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */
15621562
if (!DeleteTimerQueueTimer(NULL, tq_timer, INVALID_HANDLE_VALUE)) {
15631563
tq_timer = NULL;
15641564
zend_error_noreturn(E_ERROR, "Could not delete queued timer");
1565-
return;
15661565
}
15671566
tq_timer = NULL;
15681567
}
@@ -1572,7 +1571,6 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */
15721571
if (!CreateTimerQueueTimer(&tq_timer, NULL, (WAITORTIMERCALLBACK)tq_timer_cb, (VOID*)eg, seconds*1000, 0, WT_EXECUTEONLYONCE)) {
15731572
tq_timer = NULL;
15741573
zend_error_noreturn(E_ERROR, "Could not queue new timer");
1575-
return;
15761574
}
15771575
#elif defined(ZEND_MAX_EXECUTION_TIMERS)
15781576
if (seconds > 0) {
@@ -1659,7 +1657,6 @@ void zend_unset_timeout(void) /* {{{ */
16591657
zend_atomic_bool_store_ex(&EG(timed_out), false);
16601658
tq_timer = NULL;
16611659
zend_error_noreturn(E_ERROR, "Could not delete queued timer");
1662-
return;
16631660
}
16641661
tq_timer = NULL;
16651662
}

Zend/zend_inheritance.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,6 @@ static void zend_do_implement_interfaces(zend_class_entry *ce, zend_class_entry
22732273
zend_get_object_type_uc(ce),
22742274
ZSTR_VAL(ce->name),
22752275
ZSTR_VAL(iface->name));
2276-
return;
22772276
}
22782277
/* skip duplications */
22792278
ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&iface->constants_table, key, c) {
@@ -2524,7 +2523,6 @@ static uint32_t zend_check_trait_usage(const zend_class_entry *ce, const zend_cl
25242523
{
25252524
if (UNEXPECTED((trait->ce_flags & ZEND_ACC_TRAIT) != ZEND_ACC_TRAIT)) {
25262525
zend_error_noreturn(E_COMPILE_ERROR, "Class %s is not a trait, Only traits may be used in 'as' and 'insteadof' statements", ZSTR_VAL(trait->name));
2527-
return 0;
25282526
}
25292527

25302528
for (uint32_t i = 0; i < ce->num_traits; i++) {
@@ -2533,7 +2531,6 @@ static uint32_t zend_check_trait_usage(const zend_class_entry *ce, const zend_cl
25332531
}
25342532
}
25352533
zend_error_noreturn(E_COMPILE_ERROR, "Required Trait %s wasn't added to %s", ZSTR_VAL(trait->name), ZSTR_VAL(ce->name));
2536-
return 0;
25372534
}
25382535
/* }}} */
25392536

Zend/zend_vm_execute.h

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Zend/zend_vm_gen.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,6 @@ function gen_null_handler($f, $kind) {
15831583
out($f,"\n");
15841584
out($f,"\tSAVE_OPLINE();\n");
15851585
out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n");
1586-
out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n");
15871586
out($f,"}\n\n");
15881587
}
15891588

@@ -1812,12 +1811,10 @@ function gen_executor_code($f, $spec, $kind, $prolog, &$switch_labels = array())
18121811
case ZEND_VM_KIND_SWITCH:
18131812
out($f,"default: ZEND_NULL_LABEL:\n");
18141813
out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n");
1815-
out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n");
18161814
break;
18171815
case ZEND_VM_KIND_GOTO:
18181816
out($f,"ZEND_NULL_LABEL:\n");
18191817
out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n");
1820-
out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n");
18211818
break;
18221819
case ZEND_VM_KIND_HYBRID:
18231820
out($f,"\t\t\tHYBRID_CASE(HYBRID_HALT):\n");

ext/pdo/pdo.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,9 @@ PDO_API zend_result php_pdo_register_driver(const pdo_driver_t *driver) /* {{{ *
115115
if (driver->api_version != PDO_DRIVER_API) {
116116
zend_error_noreturn(E_ERROR, "PDO: driver %s requires PDO API version " ZEND_ULONG_FMT "; this is PDO version %d",
117117
driver->driver_name, driver->api_version, PDO_DRIVER_API);
118-
return FAILURE;
119118
}
120119
if (!zend_hash_str_exists(&module_registry, "pdo", sizeof("pdo") - 1)) {
121120
zend_error_noreturn(E_ERROR, "The PDO extension must be loaded first in order to load PDO drivers");
122-
return FAILURE; /* NOTREACHED */
123121
}
124122

125123
return zend_hash_str_add_ptr(&pdo_driver_hash, driver->driver_name, driver->driver_name_len, (void*)driver) != NULL ? SUCCESS : FAILURE;
@@ -141,7 +139,6 @@ PDO_API zend_result php_pdo_register_driver_specific_ce(const pdo_driver_t *driv
141139
{
142140
if (!zend_hash_str_exists(&module_registry, "pdo", sizeof("pdo") - 1)) {
143141
zend_error_noreturn(E_ERROR, "The PDO extension must be loaded first in order to load PDO drivers");
144-
return FAILURE; /* NOTREACHED */
145142
}
146143

147144
return zend_hash_str_add_ptr(&pdo_driver_specific_ce_hash, driver->driver_name,

ext/pgsql/pgsql.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3676,7 +3676,6 @@ PHP_FUNCTION(pg_unescape_bytea)
36763676
tmp = (char *)PQunescapeBytea((unsigned char*)from, &to_len);
36773677
if (!tmp) {
36783678
zend_error_noreturn(E_ERROR, "Out of memory");
3679-
return;
36803679
}
36813680

36823681
RETVAL_STRINGL(tmp, to_len);

main/output.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ PHPAPI zend_result php_output_handler_conflict_register(const char *name, size_t
609609

610610
if (!EG(current_module)) {
611611
zend_error_noreturn(E_ERROR, "Cannot register an output handler conflict outside of MINIT");
612-
return FAILURE;
613612
}
614613
str = zend_string_init_interned(name, name_len, 1);
615614
zend_hash_update_ptr(&php_output_handler_conflicts, str, check_func);
@@ -626,7 +625,6 @@ PHPAPI zend_result php_output_handler_reverse_conflict_register(const char *name
626625

627626
if (!EG(current_module)) {
628627
zend_error_noreturn(E_ERROR, "Cannot register a reverse output handler conflict outside of MINIT");
629-
return FAILURE;
630628
}
631629

632630
if (NULL != (rev_ptr = zend_hash_str_find_ptr(&php_output_handler_reverse_conflicts, name, name_len))) {
@@ -663,7 +661,6 @@ PHPAPI zend_result php_output_handler_alias_register(const char *name, size_t na
663661

664662
if (!EG(current_module)) {
665663
zend_error_noreturn(E_ERROR, "Cannot register an output handler alias outside of MINIT");
666-
return FAILURE;
667664
}
668665
str = zend_string_init_interned(name, name_len, 1);
669666
zend_hash_update_ptr(&php_output_handler_aliases, str, func);

0 commit comments

Comments
 (0)