Skip to content

Commit 692cea5

Browse files
committed
Use zend_error_noreturn for E_ERROR consistently
To be clear, these already don't return. zend_error_noreturn just hints at this fact through the ZEND_NORETURN attribute. Closes GH-12204
1 parent 2227fef commit 692cea5

File tree

15 files changed

+26
-26
lines changed

15 files changed

+26
-26
lines changed

Zend/zend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const c
17251725
if (EG(current_execute_data) && !CG(in_compilation)) {
17261726
zend_throw_exception(exception_ce, message, 0);
17271727
} else {
1728-
zend_error(E_ERROR, "%s", message);
1728+
zend_error_noreturn(E_ERROR, "%s", message);
17291729
}
17301730

17311731
efree(message);

Zend/zend_arena.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static zend_always_inline void* zend_arena_calloc(zend_arena **arena_ptr, size_t
8484

8585
size = zend_safe_address(unit_size, count, 0, &overflow);
8686
if (UNEXPECTED(overflow)) {
87-
zend_error(E_ERROR, "Possible integer overflow in zend_arena_calloc() (%zu * %zu)", unit_size, count);
87+
zend_error_noreturn(E_ERROR, "Possible integer overflow in zend_arena_calloc() (%zu * %zu)", unit_size, count);
8888
}
8989
ret = zend_arena_alloc(arena_ptr, size);
9090
memset(ret, 0, size);
@@ -180,7 +180,7 @@ static zend_always_inline void* zend_arena_calloc(zend_arena **arena_ptr, size_t
180180

181181
size = zend_safe_address(unit_size, count, 0, &overflow);
182182
if (UNEXPECTED(overflow)) {
183-
zend_error(E_ERROR, "Possible integer overflow in zend_arena_calloc() (%zu * %zu)", unit_size, count);
183+
zend_error_noreturn(E_ERROR, "Possible integer overflow in zend_arena_calloc() (%zu * %zu)", unit_size, count);
184184
}
185185
ret = zend_arena_alloc(arena_ptr, size);
186186
memset(ret, 0, size);

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ ZEND_API bool zend_internal_call_should_throw(zend_function *fbc, zend_execute_d
12971297

12981298
ZEND_API ZEND_COLD void zend_internal_call_arginfo_violation(zend_function *fbc)
12991299
{
1300-
zend_error(E_ERROR, "Arginfo / zpp mismatch during call of %s%s%s()",
1300+
zend_error_noreturn(E_ERROR, "Arginfo / zpp mismatch during call of %s%s%s()",
13011301
fbc->common.scope ? ZSTR_VAL(fbc->common.scope->name) : "",
13021302
fbc->common.scope ? "::" : "",
13031303
ZSTR_VAL(fbc->common.function_name));

Zend/zend_execute_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static ZEND_COLD void zend_throw_or_error(int fetch_type, zend_class_entry *exce
240240
if (fetch_type & ZEND_FETCH_CLASS_EXCEPTION) {
241241
zend_throw_error(exception_ce, "%s", message);
242242
} else {
243-
zend_error(E_ERROR, "%s", message);
243+
zend_error_noreturn(E_ERROR, "%s", message);
244244
}
245245

246246
efree(message);

Zend/zend_smart_str.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ ZEND_API void ZEND_FASTCALL _smart_string_alloc_persistent(smart_string *str, si
147147
str->c = pemalloc(str->a + 1, 1);
148148
} else {
149149
if (UNEXPECTED((size_t) len > SIZE_MAX - str->len)) {
150-
zend_error(E_ERROR, "String size overflow");
150+
zend_error_noreturn(E_ERROR, "String size overflow");
151151
}
152152
len += str->len;
153153
str->a = ZEND_MM_ALIGNED_SIZE_EX(len + SMART_STRING_OVERHEAD, SMART_STRING_PAGE) - SMART_STRING_OVERHEAD;
@@ -173,7 +173,7 @@ ZEND_API void ZEND_FASTCALL _smart_string_alloc(smart_string *str, size_t len)
173173
}
174174
} else {
175175
if (UNEXPECTED((size_t) len > SIZE_MAX - str->len)) {
176-
zend_error(E_ERROR, "String size overflow");
176+
zend_error_noreturn(E_ERROR, "String size overflow");
177177
}
178178
len += str->len;
179179
str->a = ZEND_MM_ALIGNED_SIZE_EX(len + SMART_STRING_OVERHEAD, SMART_STRING_PAGE) - SMART_STRING_OVERHEAD;

ext/date/php_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ static int implement_date_interface_handler(zend_class_entry *interface, zend_cl
17231723
!instanceof_function(implementor, date_ce_date) &&
17241724
!instanceof_function(implementor, date_ce_immutable)
17251725
) {
1726-
zend_error(E_ERROR, "DateTimeInterface can't be implemented by user classes");
1726+
zend_error_noreturn(E_ERROR, "DateTimeInterface can't be implemented by user classes");
17271727
}
17281728

17291729
return SUCCESS;

ext/ffi/ffi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ static void zend_ffi_callback_trampoline(ffi_cif* cif, void* ret, void** args, v
976976
free_alloca(fci.params, use_heap);
977977

978978
if (EG(exception)) {
979-
zend_error(E_ERROR, "Throwing from FFI callbacks is not allowed");
979+
zend_error_noreturn(E_ERROR, "Throwing from FFI callbacks is not allowed");
980980
}
981981

982982
ret_type = ZEND_FFI_TYPE(callback_data->type->func.ret_type);

ext/gd/libgd/gd_webp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile)
5656
if (filedata) {
5757
gdFree(filedata);
5858
}
59-
zend_error(E_ERROR, "WebP decode: realloc failed");
59+
zend_error_noreturn(E_ERROR, "WebP decode: realloc failed");
6060
return NULL;
6161
}
6262

@@ -67,7 +67,7 @@ gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile)
6767
} while (n>0 && n!=EOF);
6868

6969
if (WebPGetInfo(filedata,size, &width, &height) == 0) {
70-
zend_error(E_ERROR, "gd-webp cannot get webp info");
70+
zend_error_noreturn(E_ERROR, "gd-webp cannot get webp info");
7171
gdFree(filedata);
7272
return NULL;
7373
}
@@ -79,7 +79,7 @@ gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile)
7979
}
8080
argb = WebPDecodeARGB(filedata, size, &width, &height);
8181
if (!argb) {
82-
zend_error(E_ERROR, "gd-webp cannot allocate temporary buffer");
82+
zend_error_noreturn(E_ERROR, "gd-webp cannot allocate temporary buffer");
8383
gdFree(filedata);
8484
gdImageDestroy(im);
8585
return NULL;
@@ -113,7 +113,7 @@ void gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
113113
}
114114

115115
if (!gdImageTrueColor(im)) {
116-
zend_error(E_ERROR, "Palette image not supported by webp");
116+
zend_error_noreturn(E_ERROR, "Palette image not supported by webp");
117117
return;
118118
}
119119

@@ -159,7 +159,7 @@ void gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
159159
}
160160

161161
if (out_size == 0) {
162-
zend_error(E_ERROR, "gd-webp encoding failed");
162+
zend_error_noreturn(E_ERROR, "gd-webp encoding failed");
163163
goto freeargb;
164164
}
165165
gdPutBuf(out, out_size, outfile);

ext/intl/spoofchecker/spoofchecker_class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static zend_object *spoofchecker_clone_obj(zend_object *object) /* {{{ */
7777
/* set up error in case error handler is interested */
7878
intl_error_set( NULL, SPOOFCHECKER_ERROR_CODE(new_sfo), "Failed to clone SpoofChecker object", 0 );
7979
Spoofchecker_objects_free(&new_sfo->zo); /* free new object */
80-
zend_error(E_ERROR, "Failed to clone SpoofChecker object");
80+
zend_error_noreturn(E_ERROR, "Failed to clone SpoofChecker object");
8181
}
8282
return new_obj_val;
8383
}

ext/opcache/zend_accelerator_util_funcs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,12 @@ static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target,
178178
CG(zend_lineno) = function1->op_array.opcodes[0].lineno;
179179
if (function2->type == ZEND_USER_FUNCTION
180180
&& function2->op_array.last > 0) {
181-
zend_error(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)",
181+
zend_error_noreturn(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)",
182182
ZSTR_VAL(function1->common.function_name),
183183
ZSTR_VAL(function2->op_array.filename),
184184
(int)function2->op_array.opcodes[0].lineno);
185185
} else {
186-
zend_error(E_ERROR, "Cannot redeclare %s()", ZSTR_VAL(function1->common.function_name));
186+
zend_error_noreturn(E_ERROR, "Cannot redeclare %s()", ZSTR_VAL(function1->common.function_name));
187187
}
188188
}
189189

@@ -227,7 +227,7 @@ static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, Ha
227227
CG(in_compilation) = 1;
228228
zend_set_compiled_filename(ce1->info.user.filename);
229229
CG(zend_lineno) = ce1->info.user.line_start;
230-
zend_error(E_ERROR,
230+
zend_error_noreturn(E_ERROR,
231231
"Cannot declare %s %s, because the name is already in use",
232232
zend_get_object_type(ce1), ZSTR_VAL(ce1->name));
233233
return;

0 commit comments

Comments
 (0)