diff options
author | Máté Kocsis <kocsismate@woohoolabs.com> | 2019-12-29 20:54:57 +0100 |
---|---|---|
committer | Máté Kocsis <kocsismate@woohoolabs.com> | 2019-12-30 17:38:10 +0100 |
commit | 31cf9a7ea99e69ed2838ab0765a1aefd6609ef7b (patch) | |
tree | 3fd516912d51606d822ec38e3949584d6dd6bc4e /ext/standard/array.c | |
parent | d21ad4d955289687f2b25ff5b3b4ff314c3accdd (diff) | |
download | php-git-31cf9a7ea99e69ed2838ab0765a1aefd6609ef7b.tar.gz |
Use RETURN_THROWS() when an exception is thrown
Closes GH-5036
Diffstat (limited to 'ext/standard/array.c')
-rw-r--r-- | ext/standard/array.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index a47aee5ee3..4056ff60ad 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1264,7 +1264,7 @@ PHP_FUNCTION(min) ZVAL_COPY_DEREF(return_value, result); } else { zend_value_error("Array must contain at least one element"); - return; + RETURN_THROWS(); } } } else { @@ -1311,7 +1311,7 @@ PHP_FUNCTION(max) ZVAL_COPY_DEREF(return_value, result); } else { zend_value_error("Array must contain at least one element"); - return; + RETURN_THROWS(); } } } else { @@ -2452,18 +2452,18 @@ PHP_FUNCTION(extract) if (extract_type < EXTR_OVERWRITE || extract_type > EXTR_IF_EXISTS) { zend_value_error("Invalid extract type"); - return; + RETURN_THROWS(); } if (extract_type > EXTR_SKIP && extract_type <= EXTR_PREFIX_IF_EXISTS && ZEND_NUM_ARGS() < 3) { zend_value_error("Specified extract type requires the prefix parameter"); - return; + RETURN_THROWS(); } if (prefix) { if (ZSTR_LEN(prefix) && !php_valid_var_name(ZSTR_VAL(prefix), ZSTR_LEN(prefix))) { zend_value_error("Prefix is not a valid identifier"); - return; + RETURN_THROWS(); } } @@ -2620,10 +2620,10 @@ PHP_FUNCTION(array_fill) if (EXPECTED(num > 0)) { if (sizeof(num) > 4 && UNEXPECTED(EXPECTED(num > 0x7fffffff))) { zend_value_error("Too many elements"); - return; + RETURN_THROWS(); } else if (UNEXPECTED(start_key > ZEND_LONG_MAX - num + 1)) { zend_throw_error(NULL, "Cannot add element to the array as the next element is already occupied"); - return; + RETURN_THROWS(); } else if (EXPECTED(start_key >= 0) && EXPECTED(start_key < num)) { /* create packed array */ Bucket *p; @@ -2669,7 +2669,7 @@ PHP_FUNCTION(array_fill) RETURN_EMPTY_ARRAY(); } else { zend_value_error("Number of elements can't be negative"); - return; + RETURN_THROWS(); } } /* }}} */ @@ -2708,7 +2708,7 @@ PHP_FUNCTION(array_fill_keys) if (__calc_size >= (double)HT_MAX_SIZE) { \ zend_value_error(\ "The supplied range exceeds the maximum array size: start=%0.0f end=%0.0f", end, start); \ - return; \ + RETURN_THROWS(); \ } \ size = (uint32_t)_php_math_round(__calc_size, 0, PHP_ROUND_HALF_UP); \ array_init_size(return_value, size); \ @@ -2720,7 +2720,7 @@ PHP_FUNCTION(array_fill_keys) if (__calc_size >= HT_MAX_SIZE - 1) { \ zend_value_error(\ "The supplied range exceeds the maximum array size: start=" ZEND_LONG_FMT " end=" ZEND_LONG_FMT, end, start); \ - return; \ + RETURN_THROWS(); \ } \ size = (uint32_t)(__calc_size + 1); \ array_init_size(return_value, size); \ @@ -2817,7 +2817,7 @@ double_str: if (zend_isinf(high) || zend_isinf(low)) { zend_value_error("Invalid range supplied: start=%0.0f end=%0.0f", low, high); - return; + RETURN_THROWS(); } if (low > high) { /* Negative steps */ @@ -2910,7 +2910,7 @@ long_str: err: if (err) { zend_value_error("Step exceeds the specified range"); - return; + RETURN_THROWS(); } } /* }}} */ @@ -4390,7 +4390,7 @@ PHP_FUNCTION(array_pad) pad_size_abs = ZEND_ABS(pad_size); if (pad_size_abs < 0 || pad_size_abs - input_size > Z_L(1048576)) { zend_value_error("You may only pad up to 1048576 elements at a time"); - return; + RETURN_THROWS(); } if (input_size >= pad_size_abs) { @@ -4715,7 +4715,7 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa } if (zend_parse_parameters(ZEND_NUM_ARGS(), param_spec, &args, &argc, &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) { - return; + RETURN_THROWS(); } for (i = 0; i < argc; i++) { @@ -4809,7 +4809,7 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int } if (zend_parse_parameters(ZEND_NUM_ARGS(), param_spec, &args, &arr_argc, &fci1, &fci1_cache) == FAILURE) { - return; + RETURN_THROWS(); } fci_data = &fci1; fci_data_cache = &fci1_cache; @@ -4861,7 +4861,7 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int } if (zend_parse_parameters(ZEND_NUM_ARGS(), param_spec, &args, &arr_argc, &fci1, &fci1_cache, &fci2, &fci2_cache) == FAILURE) { - return; + RETURN_THROWS(); } } else { @@ -5107,7 +5107,7 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty return; } if (zend_parse_parameters(ZEND_NUM_ARGS(), "+f", &args, &argc, &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) { - return; + RETURN_THROWS(); } diff_data_compare_func = zval_user_compare; } else { @@ -5116,7 +5116,7 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty return; } if (zend_parse_parameters(ZEND_NUM_ARGS(), "+", &args, &argc) == FAILURE) { - return; + RETURN_THROWS(); } if (data_compare_type == DIFF_COMP_DATA_INTERNAL) { diff_data_compare_func = zval_compare; @@ -5214,7 +5214,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_ } if (zend_parse_parameters(ZEND_NUM_ARGS(), param_spec, &args, &arr_argc, &fci1, &fci1_cache) == FAILURE) { - return; + RETURN_THROWS(); } fci_data = &fci1; fci_data_cache = &fci1_cache; @@ -5266,7 +5266,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_ } if (zend_parse_parameters(ZEND_NUM_ARGS(), param_spec, &args, &arr_argc, &fci1, &fci1_cache, &fci2, &fci2_cache) == FAILURE) { - return; + RETURN_THROWS(); } } else { @@ -5854,7 +5854,7 @@ PHP_FUNCTION(array_rand) if (num_avail == 0) { zend_value_error("Array is empty"); - return; + RETURN_THROWS(); } if (num_req == 1) { @@ -5895,7 +5895,7 @@ PHP_FUNCTION(array_rand) if (num_req <= 0 || num_req > num_avail) { zend_value_error("Second argument has to be between 1 and the number of elements in the array"); - return; + RETURN_THROWS(); } /* Make the return value an array only if we need to pass back more than one result. */ |