Skip to content

Commit 8176059

Browse files
committed
Use RETURN_THROWS() during ZPP in the remaining extensions
In reflection, sodium, and SPL
1 parent 062744f commit 8176059

File tree

10 files changed

+513
-513
lines changed

10 files changed

+513
-513
lines changed

ext/reflection/php_reflection.c

Lines changed: 167 additions & 167 deletions
Large diffs are not rendered by default.

ext/sodium/libsodium.c

Lines changed: 84 additions & 84 deletions
Large diffs are not rendered by default.

ext/spl/php_spl.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ PHP_FUNCTION(class_parents)
8989
zend_bool autoload = 1;
9090

9191
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &obj, &autoload) == FAILURE) {
92-
return;
92+
RETURN_THROWS();
9393
}
9494

9595
if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
@@ -123,7 +123,7 @@ PHP_FUNCTION(class_implements)
123123
zend_class_entry *ce;
124124

125125
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &obj, &autoload) == FAILURE) {
126-
return;
126+
RETURN_THROWS();
127127
}
128128
if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
129129
zend_type_error("object or string expected");
@@ -152,7 +152,7 @@ PHP_FUNCTION(class_uses)
152152
zend_class_entry *ce;
153153

154154
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &obj, &autoload) == FAILURE) {
155-
return;
155+
RETURN_THROWS();
156156
}
157157
if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
158158
zend_type_error("object or string expected");
@@ -237,7 +237,7 @@ PHP_FUNCTION(class_uses)
237237
PHP_FUNCTION(spl_classes)
238238
{
239239
if (zend_parse_parameters_none() == FAILURE) {
240-
return;
240+
RETURN_THROWS();
241241
}
242242

243243
array_init(return_value);
@@ -313,7 +313,7 @@ PHP_FUNCTION(spl_autoload)
313313
zend_string *class_name, *lc_name, *file_exts = SPL_G(autoload_extensions);
314314

315315
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|S", &class_name, &file_exts) == FAILURE) {
316-
return;
316+
RETURN_THROWS();
317317
}
318318

319319
if (file_exts == NULL) { /* autoload_extensions is not initialized, set to defaults */
@@ -348,7 +348,7 @@ PHP_FUNCTION(spl_autoload_extensions)
348348
zend_string *file_exts = NULL;
349349

350350
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &file_exts) == FAILURE) {
351-
return;
351+
RETURN_THROWS();
352352
}
353353
if (file_exts) {
354354
if (SPL_G(autoload_extensions)) {
@@ -398,7 +398,7 @@ PHP_FUNCTION(spl_autoload_call)
398398
autoload_func_info *alfi;
399399

400400
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &class_name) == FAILURE || Z_TYPE_P(class_name) != IS_STRING) {
401-
return;
401+
RETURN_THROWS();
402402
}
403403

404404
if (SPL_G(autoload_functions)) {
@@ -512,7 +512,7 @@ PHP_FUNCTION(spl_autoload_register)
512512
zend_fcall_info_cache fcc;
513513

514514
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zbb", &zcallable, &do_throw, &prepend) == FAILURE) {
515-
return;
515+
RETURN_THROWS();
516516
}
517517

518518
if (ZEND_NUM_ARGS()) {
@@ -684,7 +684,7 @@ PHP_FUNCTION(spl_autoload_unregister)
684684
zend_fcall_info_cache fcc;
685685

686686
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zcallable) == FAILURE) {
687-
return;
687+
RETURN_THROWS();
688688
}
689689

690690
if (!zend_is_callable_ex(zcallable, NULL, IS_CALLABLE_CHECK_SYNTAX_ONLY, &func_name, &fcc, &error)) {
@@ -762,7 +762,7 @@ PHP_FUNCTION(spl_autoload_functions)
762762
autoload_func_info *alfi;
763763

764764
if (zend_parse_parameters_none() == FAILURE) {
765-
return;
765+
RETURN_THROWS();
766766
}
767767

768768
if (!EG(autoload_func)) {
@@ -812,7 +812,7 @@ PHP_FUNCTION(spl_object_hash)
812812
zval *obj;
813813

814814
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &obj) == FAILURE) {
815-
return;
815+
RETURN_THROWS();
816816
}
817817

818818
RETURN_NEW_STR(php_spl_object_hash(obj));

ext/spl/spl_array.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ SPL_METHOD(Array, offsetExists)
703703
{
704704
zval *index;
705705
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &index) == FAILURE) {
706-
return;
706+
RETURN_THROWS();
707707
}
708708
RETURN_BOOL(spl_array_has_dimension_ex(0, Z_OBJ_P(ZEND_THIS), index, 2));
709709
} /* }}} */
@@ -715,7 +715,7 @@ SPL_METHOD(Array, offsetGet)
715715
{
716716
zval *value, *index;
717717
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &index) == FAILURE) {
718-
return;
718+
RETURN_THROWS();
719719
}
720720
value = spl_array_read_dimension_ex(0, Z_OBJ_P(ZEND_THIS), index, BP_VAR_R, return_value);
721721
if (value != return_value) {
@@ -730,7 +730,7 @@ SPL_METHOD(Array, offsetSet)
730730
{
731731
zval *index, *value;
732732
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &index, &value) == FAILURE) {
733-
return;
733+
RETURN_THROWS();
734734
}
735735
spl_array_write_dimension_ex(0, Z_OBJ_P(ZEND_THIS), index, value);
736736
} /* }}} */
@@ -755,7 +755,7 @@ SPL_METHOD(Array, append)
755755
zval *value;
756756

757757
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &value) == FAILURE) {
758-
return;
758+
RETURN_THROWS();
759759
}
760760
spl_array_iterator_append(ZEND_THIS, value);
761761
} /* }}} */
@@ -767,7 +767,7 @@ SPL_METHOD(Array, offsetUnset)
767767
{
768768
zval *index;
769769
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &index) == FAILURE) {
770-
return;
770+
RETURN_THROWS();
771771
}
772772
spl_array_unset_dimension_ex(0, Z_OBJ_P(ZEND_THIS), index);
773773
} /* }}} */
@@ -1197,7 +1197,7 @@ SPL_METHOD(Array, __construct)
11971197
}
11981198

11991199
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) {
1200-
return;
1200+
RETURN_THROWS();
12011201
}
12021202

12031203
intern = Z_SPLARRAY_P(object);
@@ -1226,7 +1226,7 @@ SPL_METHOD(ArrayIterator, __construct)
12261226
}
12271227

12281228
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|l", &array, &ar_flags) == FAILURE) {
1229-
return;
1229+
RETURN_THROWS();
12301230
}
12311231

12321232
intern = Z_SPLARRAY_P(object);
@@ -1261,7 +1261,7 @@ SPL_METHOD(Array, getIteratorClass)
12611261
spl_array_object *intern = Z_SPLARRAY_P(object);
12621262

12631263
if (zend_parse_parameters_none() == FAILURE) {
1264-
return;
1264+
RETURN_THROWS();
12651265
}
12661266

12671267
zend_string_addref(intern->ce_get_iterator->name);
@@ -1277,7 +1277,7 @@ SPL_METHOD(Array, getFlags)
12771277
spl_array_object *intern = Z_SPLARRAY_P(object);
12781278

12791279
if (zend_parse_parameters_none() == FAILURE) {
1280-
return;
1280+
RETURN_THROWS();
12811281
}
12821282

12831283
RETURN_LONG(intern->ar_flags & ~SPL_ARRAY_INT_MASK);
@@ -1293,7 +1293,7 @@ SPL_METHOD(Array, setFlags)
12931293
zend_long ar_flags = 0;
12941294

12951295
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ar_flags) == FAILURE) {
1296-
return;
1296+
RETURN_THROWS();
12971297
}
12981298

12991299
intern->ar_flags = (intern->ar_flags & SPL_ARRAY_INT_MASK) | (ar_flags & ~SPL_ARRAY_INT_MASK);
@@ -1308,7 +1308,7 @@ SPL_METHOD(Array, exchangeArray)
13081308
spl_array_object *intern = Z_SPLARRAY_P(object);
13091309

13101310
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &array) == FAILURE) {
1311-
return;
1311+
RETURN_THROWS();
13121312
}
13131313

13141314
if (intern->nApplyCount > 0) {
@@ -1329,7 +1329,7 @@ SPL_METHOD(Array, getIterator)
13291329
spl_array_object *intern = Z_SPLARRAY_P(object);
13301330

13311331
if (zend_parse_parameters_none() == FAILURE) {
1332-
return;
1332+
RETURN_THROWS();
13331333
}
13341334

13351335
ZVAL_OBJ(return_value, spl_array_object_new_ex(intern->ce_get_iterator, Z_OBJ_P(object), 0));
@@ -1344,7 +1344,7 @@ SPL_METHOD(Array, rewind)
13441344
spl_array_object *intern = Z_SPLARRAY_P(object);
13451345

13461346
if (zend_parse_parameters_none() == FAILURE) {
1347-
return;
1347+
RETURN_THROWS();
13481348
}
13491349

13501350
spl_array_rewind(intern);
@@ -1362,7 +1362,7 @@ SPL_METHOD(Array, seek)
13621362
int result;
13631363

13641364
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &position) == FAILURE) {
1365-
return;
1365+
RETURN_THROWS();
13661366
}
13671367

13681368
opos = position;
@@ -1428,7 +1428,7 @@ SPL_METHOD(Array, count)
14281428
spl_array_object *intern = Z_SPLARRAY_P(ZEND_THIS);
14291429

14301430
if (zend_parse_parameters_none() == FAILURE) {
1431-
return;
1431+
RETURN_THROWS();
14321432
}
14331433

14341434
RETURN_LONG(spl_array_object_count_elements_helper(intern));
@@ -1532,7 +1532,7 @@ SPL_METHOD(Array, current)
15321532
HashTable *aht = spl_array_get_hash_table(intern);
15331533

15341534
if (zend_parse_parameters_none() == FAILURE) {
1535-
return;
1535+
RETURN_THROWS();
15361536
}
15371537

15381538
if ((entry = zend_hash_get_current_data_ex(aht, spl_array_get_pos_ptr(aht, intern))) == NULL) {
@@ -1553,7 +1553,7 @@ SPL_METHOD(Array, current)
15531553
SPL_METHOD(Array, key)
15541554
{
15551555
if (zend_parse_parameters_none() == FAILURE) {
1556-
return;
1556+
RETURN_THROWS();
15571557
}
15581558

15591559
spl_array_iterator_key(ZEND_THIS, return_value);
@@ -1577,7 +1577,7 @@ SPL_METHOD(Array, next)
15771577
HashTable *aht = spl_array_get_hash_table(intern);
15781578

15791579
if (zend_parse_parameters_none() == FAILURE) {
1580-
return;
1580+
RETURN_THROWS();
15811581
}
15821582

15831583
spl_array_next_ex(intern, aht);
@@ -1593,7 +1593,7 @@ SPL_METHOD(Array, valid)
15931593
HashTable *aht = spl_array_get_hash_table(intern);
15941594

15951595
if (zend_parse_parameters_none() == FAILURE) {
1596-
return;
1596+
RETURN_THROWS();
15971597
}
15981598

15991599
RETURN_BOOL(zend_hash_has_more_elements_ex(aht, spl_array_get_pos_ptr(aht, intern)) == SUCCESS);
@@ -1609,7 +1609,7 @@ SPL_METHOD(Array, hasChildren)
16091609
HashTable *aht = spl_array_get_hash_table(intern);
16101610

16111611
if (zend_parse_parameters_none() == FAILURE) {
1612-
return;
1612+
RETURN_THROWS();
16131613
}
16141614

16151615
if ((entry = zend_hash_get_current_data_ex(aht, spl_array_get_pos_ptr(aht, intern))) == NULL) {
@@ -1634,7 +1634,7 @@ SPL_METHOD(Array, getChildren)
16341634
HashTable *aht = spl_array_get_hash_table(intern);
16351635

16361636
if (zend_parse_parameters_none() == FAILURE) {
1637-
return;
1637+
RETURN_THROWS();
16381638
}
16391639

16401640
if ((entry = zend_hash_get_current_data_ex(aht, spl_array_get_pos_ptr(aht, intern))) == NULL) {
@@ -1725,7 +1725,7 @@ SPL_METHOD(Array, unserialize)
17251725
zend_long flags;
17261726

17271727
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &buf, &buf_len) == FAILURE) {
1728-
return;
1728+
RETURN_THROWS();
17291729
}
17301730

17311731
if (buf_len == 0) {
@@ -1830,7 +1830,7 @@ SPL_METHOD(Array, __serialize)
18301830
zval tmp;
18311831

18321832
if (zend_parse_parameters_none_throw() == FAILURE) {
1833-
return;
1833+
RETURN_THROWS();
18341834
}
18351835

18361836
array_init(return_value);
@@ -1864,7 +1864,7 @@ SPL_METHOD(Array, __unserialize)
18641864
zend_long flags;
18651865

18661866
if (zend_parse_parameters(ZEND_NUM_ARGS(), "h", &data) == FAILURE) {
1867-
return;
1867+
RETURN_THROWS();
18681868
}
18691869

18701870
flags_zv = zend_hash_index_find(data, 0);

0 commit comments

Comments
 (0)