Skip to content

Commit 349a286

Browse files
committed
Use RETURN_THROWS() after zend_throw_error()
1 parent 9099dbd commit 349a286

File tree

14 files changed

+60
-60
lines changed

14 files changed

+60
-60
lines changed

Zend/zend_exceptions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ ZEND_METHOD(exception, __construct)
289289
ce = base_ce;
290290
}
291291
zend_throw_error(NULL, "Wrong parameters for %s([string $message [, long $code [, Throwable $previous = NULL]]])", ZSTR_VAL(ce->name));
292-
return;
292+
RETURN_THROWS();
293293
}
294294

295295
if (message) {
@@ -355,7 +355,7 @@ ZEND_METHOD(error_exception, __construct)
355355
ce = zend_ce_error_exception;
356356
}
357357
zend_throw_error(NULL, "Wrong parameters for %s([string $message [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Throwable $previous = NULL]]]]]])", ZSTR_VAL(ce->name));
358-
return;
358+
RETURN_THROWS();
359359
}
360360

361361
object = ZEND_THIS;

ext/date/php_date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static zend_object_handlers date_object_handlers_period;
302302
#define DATE_CHECK_INITIALIZED(member, class_name) \
303303
if (!(member)) { \
304304
zend_throw_error(NULL, "The " #class_name " object has not been correctly initialized by its constructor"); \
305-
return; \
305+
RETURN_THROWS(); \
306306
}
307307

308308
static void date_object_free_storage_date(zend_object *object);

ext/dom/document.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,7 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type
17301730
if (!vptr) {
17311731
xmlSchemaFree(sptr);
17321732
zend_throw_error(NULL, "Invalid Schema Validation Context");
1733-
RETURN_FALSE;
1733+
RETURN_THROWS();
17341734
}
17351735

17361736
if (flags & XML_SCHEMA_VAL_VC_I_CREATE) {
@@ -1829,7 +1829,7 @@ static void _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAMETERS, int typ
18291829
if (!vptr) {
18301830
xmlRelaxNGFree(sptr);
18311831
zend_throw_error(NULL, "Invalid RelaxNG Validation Context");
1832-
RETURN_FALSE;
1832+
RETURN_THROWS();
18331833
}
18341834

18351835
xmlRelaxNGSetValidErrors(vptr, php_libxml_error_handler, php_libxml_error_handler, vptr);

ext/ffi/ffi.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,7 +2819,7 @@ ZEND_METHOD(FFI, cdef) /* {{{ */
28192819
handle = DL_LOAD(ZSTR_VAL(lib));
28202820
if (!handle) {
28212821
zend_throw_error(zend_ffi_exception_ce, "Failed loading '%s'", ZSTR_VAL(lib));
2822-
return;
2822+
RETURN_THROWS();
28232823
}
28242824
#ifdef RTLD_DEFAULT
28252825
} else if (1) {
@@ -3345,7 +3345,7 @@ ZEND_METHOD(FFI, load) /* {{{ */
33453345

33463346
if (CG(compiler_options) & ZEND_COMPILE_PRELOAD_IN_CHILD) {
33473347
zend_throw_error(zend_ffi_exception_ce, "FFI::load() doesn't work in conjunction with \"opcache.preload_user\". Use \"ffi.preload\" instead.");
3348-
return;
3348+
RETURN_THROWS();
33493349
}
33503350

33513351
ffi = zend_ffi_load(ZSTR_VAL(fn), (CG(compiler_options) & ZEND_COMPILE_PRELOAD) != 0);
@@ -3373,7 +3373,7 @@ ZEND_METHOD(FFI, scope) /* {{{ */
33733373

33743374
if (!scope) {
33753375
zend_throw_error(zend_ffi_exception_ce, "Failed loading scope '%s'", ZSTR_VAL(scope_name));
3376-
return;
3376+
RETURN_THROWS();
33773377
}
33783378

33793379
ffi = (zend_ffi*)zend_ffi_new(zend_ffi_ce);
@@ -3687,7 +3687,7 @@ ZEND_METHOD(FFI, free) /* {{{ */
36873687
if (ZEND_FFI_TYPE(cdata->type)->kind == ZEND_FFI_TYPE_POINTER) {
36883688
if (!cdata->ptr) {
36893689
zend_throw_error(zend_ffi_exception_ce, "NULL pointer dereference");
3690-
return;
3690+
RETURN_THROWS();
36913691
}
36923692
if (cdata->ptr != (void*)&cdata->ptr_holder) {
36933693
pefree(*(void**)cdata->ptr, cdata->flags & ZEND_FFI_FLAG_PERSISTENT);
@@ -3857,7 +3857,7 @@ ZEND_METHOD(FFI, cast) /* {{{ */
38573857
} else if (type->size > old_type->size) {
38583858
zend_object_release(&cdata->std);
38593859
zend_throw_error(zend_ffi_exception_ce, "attempt to cast to larger type");
3860-
return;
3860+
RETURN_THROWS();
38613861
} else if (ptr != &old_cdata->ptr_holder) {
38623862
cdata->ptr = ptr;
38633863
} else {
@@ -4001,16 +4001,16 @@ ZEND_METHOD(FFI, arrayType) /* {{{ */
40014001

40024002
if (type->kind == ZEND_FFI_TYPE_FUNC) {
40034003
zend_throw_error(zend_ffi_exception_ce, "array of functions is not allowed");
4004-
return;
4004+
RETURN_THROWS();
40054005
} else if (type->kind == ZEND_FFI_TYPE_ARRAY && (type->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY)) {
40064006
zend_throw_error(zend_ffi_exception_ce, "only the leftmost array can be undimensioned");
4007-
return;
4007+
RETURN_THROWS();
40084008
} else if (type->kind == ZEND_FFI_TYPE_VOID) {
40094009
zend_throw_error(zend_ffi_exception_ce, "array of 'void' is not allowed");
4010-
return;
4010+
RETURN_THROWS();
40114011
} else if (type->attr & ZEND_FFI_ATTR_INCOMPLETE_TAG) {
40124012
zend_throw_error(zend_ffi_exception_ce, "array of incomplete type is not allowed");
4013-
return;
4013+
RETURN_THROWS();
40144014
}
40154015

40164016
if (ZEND_FFI_TYPE_IS_OWNED(ctype->type)) {
@@ -4032,11 +4032,11 @@ ZEND_METHOD(FFI, arrayType) /* {{{ */
40324032
if (n < 0) {
40334033
zend_throw_error(zend_ffi_exception_ce, "negative array index");
40344034
zend_ffi_type_dtor(type);
4035-
return;
4035+
RETURN_THROWS();
40364036
} else if (ZEND_FFI_TYPE(type)->kind == ZEND_FFI_TYPE_ARRAY && (ZEND_FFI_TYPE(type)->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY)) {
40374037
zend_throw_error(zend_ffi_exception_ce, "only the leftmost array can be undimensioned");
40384038
zend_ffi_type_dtor(type);
4039-
return;
4039+
RETURN_THROWS();
40404040
}
40414041

40424042
new_type = emalloc(sizeof(zend_ffi_type));
@@ -4187,7 +4187,7 @@ ZEND_METHOD(FFI, memcpy) /* {{{ */
41874187
ptr1 = cdata1->ptr;
41884188
if (type1->kind != ZEND_FFI_TYPE_POINTER && size > type1->size) {
41894189
zend_throw_error(zend_ffi_exception_ce, "attempt to write over data boundary");
4190-
return;
4190+
RETURN_THROWS();
41914191
}
41924192
}
41934193

@@ -4196,7 +4196,7 @@ ZEND_METHOD(FFI, memcpy) /* {{{ */
41964196
ptr2 = Z_STRVAL_P(zv2);
41974197
if (size > Z_STRLEN_P(zv2)) {
41984198
zend_throw_error(zend_ffi_exception_ce, "attempt to read over string boundary");
4199-
return;
4199+
RETURN_THROWS();
42004200
}
42014201
} else if (Z_TYPE_P(zv2) == IS_OBJECT && Z_OBJCE_P(zv2) == zend_ffi_cdata_ce) {
42024202
cdata2 = (zend_ffi_cdata*)Z_OBJ_P(zv2);
@@ -4207,7 +4207,7 @@ ZEND_METHOD(FFI, memcpy) /* {{{ */
42074207
ptr2 = cdata2->ptr;
42084208
if (type2->kind != ZEND_FFI_TYPE_POINTER && size > type2->size) {
42094209
zend_throw_error(zend_ffi_exception_ce, "attempt to read over data boundary");
4210-
return;
4210+
RETURN_THROWS();
42114211
}
42124212
}
42134213
} else {
@@ -4240,7 +4240,7 @@ ZEND_METHOD(FFI, memcmp) /* {{{ */
42404240
ptr1 = Z_STRVAL_P(zv1);
42414241
if (size > Z_STRLEN_P(zv1)) {
42424242
zend_throw_error(zend_ffi_exception_ce, "attempt to read over string boundary");
4243-
return;
4243+
RETURN_THROWS();
42444244
}
42454245
} else if (Z_TYPE_P(zv1) == IS_OBJECT && Z_OBJCE_P(zv1) == zend_ffi_cdata_ce) {
42464246
cdata1 = (zend_ffi_cdata*)Z_OBJ_P(zv1);
@@ -4251,7 +4251,7 @@ ZEND_METHOD(FFI, memcmp) /* {{{ */
42514251
ptr1 = cdata1->ptr;
42524252
if (type1->kind != ZEND_FFI_TYPE_POINTER && size > type1->size) {
42534253
zend_throw_error(zend_ffi_exception_ce, "attempt to read over data boundary");
4254-
return;
4254+
RETURN_THROWS();
42554255
}
42564256
}
42574257
} else {
@@ -4264,7 +4264,7 @@ ZEND_METHOD(FFI, memcmp) /* {{{ */
42644264
ptr2 = Z_STRVAL_P(zv2);
42654265
if (size > Z_STRLEN_P(zv2)) {
42664266
zend_throw_error(zend_ffi_exception_ce, "attempt to read over string boundary");
4267-
return;
4267+
RETURN_THROWS();
42684268
}
42694269
} else if (Z_TYPE_P(zv2) == IS_OBJECT && Z_OBJCE_P(zv2) == zend_ffi_cdata_ce) {
42704270
cdata2 = (zend_ffi_cdata*)Z_OBJ_P(zv2);
@@ -4275,7 +4275,7 @@ ZEND_METHOD(FFI, memcmp) /* {{{ */
42754275
ptr2 = cdata2->ptr;
42764276
if (type2->kind != ZEND_FFI_TYPE_POINTER && size > type2->size) {
42774277
zend_throw_error(zend_ffi_exception_ce, "attempt to read over data boundary");
4278-
return;
4278+
RETURN_THROWS();
42794279
}
42804280
}
42814281
} else {
@@ -4317,7 +4317,7 @@ ZEND_METHOD(FFI, memset) /* {{{ */
43174317
ptr = cdata->ptr;
43184318
if (type->kind != ZEND_FFI_TYPE_POINTER && size > type->size) {
43194319
zend_throw_error(zend_ffi_exception_ce, "attempt to write over data boundary");
4320-
return;
4320+
RETURN_THROWS();
43214321
}
43224322
}
43234323

@@ -4349,7 +4349,7 @@ ZEND_METHOD(FFI, string) /* {{{ */
43494349
ptr = cdata->ptr;
43504350
if (type->kind != ZEND_FFI_TYPE_POINTER && size > type->size) {
43514351
zend_throw_error(zend_ffi_exception_ce, "attempt to read over data boundary");
4352-
return;
4352+
RETURN_THROWS();
43534353
}
43544354
}
43554355
RETURN_STRINGL((char*)ptr, size);
@@ -4360,7 +4360,7 @@ ZEND_METHOD(FFI, string) /* {{{ */
43604360
ptr = cdata->ptr;
43614361
} else {
43624362
zend_throw_error(zend_ffi_exception_ce, "FFI\\Cdata is not a C string");
4363-
return;
4363+
RETURN_THROWS();
43644364
}
43654365
RETURN_STRING((char*)ptr);
43664366
}
@@ -4389,7 +4389,7 @@ ZEND_METHOD(FFI, isNull) /* {{{ */
43894389

43904390
if (type->kind != ZEND_FFI_TYPE_POINTER){
43914391
zend_throw_error(zend_ffi_exception_ce, "FFI\\Cdata is not a pointer");
4392-
return;
4392+
RETURN_THROWS();
43934393
}
43944394

43954395
RETURN_BOOL(*(void**)cdata->ptr == NULL);

ext/hash/hash.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,17 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename,
253253
ops = php_hash_fetch_ops(algo, algo_len);
254254
if (!ops) {
255255
zend_throw_error(NULL, "Unknown hashing algorithm: %s", algo);
256-
return;
256+
RETURN_THROWS();
257257
}
258258
else if (!ops->is_crypto) {
259259
zend_throw_error(NULL, "Non-cryptographic hashing algorithm: %s", algo);
260-
return;
260+
RETURN_THROWS();
261261
}
262262

263263
if (isfilename) {
264264
if (CHECK_NULL_PATH(data, data_len)) {
265265
zend_throw_error(NULL, "Invalid path");
266-
return;
266+
RETURN_THROWS();
267267
}
268268
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, FG(default_context));
269269
if (!stream) {
@@ -359,18 +359,18 @@ PHP_FUNCTION(hash_init)
359359
ops = php_hash_fetch_ops(ZSTR_VAL(algo), ZSTR_LEN(algo));
360360
if (!ops) {
361361
zend_throw_error(NULL, "Unknown hashing algorithm: %s", ZSTR_VAL(algo));
362-
return;
362+
RETURN_THROWS();
363363
}
364364

365365
if (options & PHP_HASH_HMAC) {
366366
if (!ops->is_crypto) {
367367
zend_throw_error(NULL, "HMAC requested with a non-cryptographic hashing algorithm: %s", ZSTR_VAL(algo));
368-
return;
368+
RETURN_THROWS();
369369
}
370370
if (!key || (ZSTR_LEN(key) == 0)) {
371371
/* Note: a zero length key is no key at all */
372372
zend_throw_error(NULL, "HMAC requested without a key");
373-
return;
373+
RETURN_THROWS();
374374
}
375375
}
376376

@@ -415,7 +415,7 @@ PHP_FUNCTION(hash_init)
415415
#define PHP_HASHCONTEXT_VERIFY(func, hash) { \
416416
if (!hash->context) { \
417417
zend_throw_error(NULL, "%s(): supplied resource is not a valid Hash Context resource", func); \
418-
return; \
418+
RETURN_THROWS(); \
419419
} \
420420
}
421421

@@ -587,7 +587,7 @@ PHP_FUNCTION(hash_copy)
587587
zval_ptr_dtor(return_value);
588588

589589
zend_throw_error(NULL, "Cannot copy hash");
590-
return;
590+
RETURN_THROWS();
591591
}
592592
}
593593
/* }}} */
@@ -648,27 +648,27 @@ PHP_FUNCTION(hash_hkdf)
648648
ops = php_hash_fetch_ops(ZSTR_VAL(algo), ZSTR_LEN(algo));
649649
if (!ops) {
650650
zend_throw_error(NULL, "Unknown hashing algorithm: %s", ZSTR_VAL(algo));
651-
return;
651+
RETURN_THROWS();
652652
}
653653

654654
if (!ops->is_crypto) {
655655
zend_throw_error(NULL, "Non-cryptographic hashing algorithm: %s", ZSTR_VAL(algo));
656-
return;
656+
RETURN_THROWS();
657657
}
658658

659659
if (ZSTR_LEN(ikm) == 0) {
660660
zend_throw_error(NULL, "Input keying material cannot be empty");
661-
return;
661+
RETURN_THROWS();
662662
}
663663

664664
if (length < 0) {
665665
zend_throw_error(NULL, "Length must be greater than or equal to 0: " ZEND_LONG_FMT, length);
666-
return;
666+
RETURN_THROWS();
667667
} else if (length == 0) {
668668
length = ops->digest_size;
669669
} else if (length > (zend_long) (ops->digest_size * 255)) {
670670
zend_throw_error(NULL, "Length must be less than or equal to %zd: " ZEND_LONG_FMT, ops->digest_size * 255, length);
671-
return;
671+
RETURN_THROWS();
672672
}
673673

674674
context = emalloc(ops->context_size);
@@ -748,26 +748,26 @@ PHP_FUNCTION(hash_pbkdf2)
748748
ops = php_hash_fetch_ops(algo, algo_len);
749749
if (!ops) {
750750
zend_throw_error(NULL, "Unknown hashing algorithm: %s", algo);
751-
return;
751+
RETURN_THROWS();
752752
}
753753
else if (!ops->is_crypto) {
754754
zend_throw_error(NULL, "Non-cryptographic hashing algorithm: %s", algo);
755-
return;
755+
RETURN_THROWS();
756756
}
757757

758758
if (iterations <= 0) {
759759
zend_throw_error(NULL, "Iterations must be a positive integer: " ZEND_LONG_FMT, iterations);
760-
return;
760+
RETURN_THROWS();
761761
}
762762

763763
if (length < 0) {
764764
zend_throw_error(NULL, "Length must be greater than or equal to 0: " ZEND_LONG_FMT, length);
765-
return;
765+
RETURN_THROWS();
766766
}
767767

768768
if (salt_len > INT_MAX - 4) {
769769
zend_throw_error(NULL, "Supplied salt is too long, max of INT_MAX - 4 bytes: %zd supplied", salt_len);
770-
return;
770+
RETURN_THROWS();
771771
}
772772

773773
context = emalloc(ops->context_size);

ext/intl/collator/collator_compare.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ PHP_FUNCTION( collator_compare )
5959
"Object not initialized", 0 );
6060
zend_throw_error(NULL, "Object not initialized");
6161

62-
RETURN_FALSE;
62+
RETURN_THROWS();
6363
}
6464

6565
/*

ext/intl/collator/collator_locale.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ PHP_FUNCTION( collator_get_locale )
5252
"Object not initialized", 0 );
5353
zend_throw_error(NULL, "Object not initialized");
5454

55-
RETURN_FALSE;
55+
RETURN_THROWS();
5656
}
5757

5858
/* Get locale by specified type. */

ext/intl/collator/collator_sort.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys )
404404
"Object not initialized", 0 );
405405
zend_throw_error(NULL, "Object not initialized");
406406

407-
RETURN_FALSE;
407+
RETURN_THROWS();
408408
}
409409

410410
/*
@@ -567,7 +567,7 @@ PHP_FUNCTION( collator_get_sort_key )
567567
"Object not initialized", 0 );
568568
zend_throw_error(NULL, "Object not initialized");
569569

570-
RETURN_FALSE;
570+
RETURN_THROWS();
571571
}
572572

573573
/*

0 commit comments

Comments
 (0)