]> granicus.if.org Git - php/commitdiff
Use RETURN_THROWS() after zend_type_error()
authorMáté Kocsis <kocsismate@woohoolabs.com>
Wed, 1 Jan 2020 13:23:21 +0000 (14:23 +0100)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Wed, 1 Jan 2020 13:23:21 +0000 (14:23 +0100)
13 files changed:
ext/bz2/bz2.c
ext/gd/gd.c
ext/hash/hash.c
ext/pcre/php_pcre.c
ext/reflection/php_reflection.c
ext/spl/php_spl.c
ext/standard/array.c
ext/standard/basic_functions.c
ext/standard/dir.c
ext/standard/exec.c
ext/standard/filestat.c
ext/standard/streamsfuncs.c
ext/standard/string.c

index b32044e17e8423ed92e12fd88e0089a11b20d2d1..9b84feafe10854c1875680201a62354bb6dfecb8 100644 (file)
@@ -380,7 +380,7 @@ static PHP_FUNCTION(bzopen)
 
                if (CHECK_ZVAL_NULL_PATH(file)) {
                        zend_type_error("filename must not contain null bytes");
-                       return;
+                       RETURN_THROWS();
                }
 
                stream = php_stream_bz2open(NULL, Z_STRVAL_P(file), mode, REPORT_ERRORS, NULL);
index 60c38b620708081751e61044d66d661326032d5c..9714f3bc38cfad22c234496ea3e68d95cebd61ad 100644 (file)
@@ -3902,7 +3902,7 @@ PHP_FUNCTION(imageaffine)
                                        break;
                                default:
                                        zend_type_error("Invalid type for element %i", i);
-                                       return;
+                                       RETURN_THROWS();
                        }
                }
        }
@@ -3976,7 +3976,7 @@ PHP_FUNCTION(imageaffinematrixget)
                        double x, y;
                        if (!options || Z_TYPE_P(options) != IS_ARRAY) {
                                zend_type_error("Array expected as options when using translate or scale");
-                               return;
+                               RETURN_THROWS();
                        }
 
                        if ((tmp = zend_hash_str_find(Z_ARRVAL_P(options), "x", sizeof("x") - 1)) != NULL) {
@@ -4008,7 +4008,7 @@ PHP_FUNCTION(imageaffinematrixget)
 
                        if (!options) {
                                zend_type_error("Number is expected as option when using rotate or shear");
-                               return;
+                               RETURN_THROWS();
                        }
 
                        angle = zval_get_double(options);
@@ -4074,7 +4074,7 @@ PHP_FUNCTION(imageaffinematrixconcat)
                                        break;
                                default:
                                        zend_type_error("Matrix 1 contains invalid type for element %i", i);
-                                       return;
+                                       RETURN_THROWS();
                        }
                }
 
@@ -4091,7 +4091,7 @@ PHP_FUNCTION(imageaffinematrixconcat)
                                        break;
                                default:
                                        zend_type_error("Matrix 2 contains invalid type for element %i", i);
-                                       return;
+                                       RETURN_THROWS();
                        }
                }
        }
@@ -4285,7 +4285,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
                } else if (Z_TYPE_P(to_zval) == IS_STRING) {
                        if (CHECK_ZVAL_NULL_PATH(to_zval)) {
                                zend_type_error("Invalid 2nd parameter, filename must not contain null bytes");
-                               return;
+                               RETURN_THROWS();
                        }
 
                        stream = php_stream_open_wrapper(Z_STRVAL_P(to_zval), "wb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL);
index e51308c4dea415490f0686d02639a91831ec093d..60ab85379e9feaca8b347eb2853b586c5d1cd07e 100644 (file)
@@ -873,12 +873,12 @@ PHP_FUNCTION(hash_equals)
        /* We only allow comparing string to prevent unexpected results. */
        if (Z_TYPE_P(known_zval) != IS_STRING) {
                zend_type_error("Expected known_string to be a string, %s given", zend_zval_type_name(known_zval));
-               return;
+               RETURN_THROWS();
        }
 
        if (Z_TYPE_P(user_zval) != IS_STRING) {
                zend_type_error("Expected user_string to be a string, %s given", zend_zval_type_name(user_zval));
-               return;
+               RETURN_THROWS();
        }
 
        if (Z_STRLEN_P(known_zval) != Z_STRLEN_P(user_zval)) {
index f5f1d6f70e691bb3b31917592f8885c3283bfe08..9305fca71c62ce2564db62d18f4c71a23c5e14e7 100644 (file)
@@ -2259,7 +2259,7 @@ static void preg_replace_common(INTERNAL_FUNCTION_PARAMETERS, int is_filter)
        } else {
                if (Z_TYPE_P(regex) != IS_ARRAY) {
                        zend_type_error("Parameter mismatch, pattern is a string while replacement is an array");
-                       return;
+                       RETURN_THROWS();
                }
        }
 
index 957a866177f58cb3d6a045565660cd453bcb4a41..61a0de16d6b16157763964a6e45935437533d4e9 100644 (file)
@@ -6260,7 +6260,7 @@ ZEND_METHOD(reflection_reference, fromArrayElement)
                item = zend_symtable_find(ht, Z_STR_P(key));
        } else {
                zend_type_error("Key must be array or string");
-               return;
+               RETURN_THROWS();
        }
 
        if (!item) {
index 06371b741db71bac8194da28078d507383caa2c7..5c42801a753ab1dbf6763afeb984b87c3bffcf8b 100644 (file)
@@ -94,7 +94,7 @@ PHP_FUNCTION(class_parents)
 
        if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
                zend_type_error("object or string expected");
-               return;
+               RETURN_THROWS();
        }
 
        if (Z_TYPE_P(obj) == IS_STRING) {
@@ -127,7 +127,7 @@ PHP_FUNCTION(class_implements)
        }
        if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
                zend_type_error("object or string expected");
-               return;
+               RETURN_THROWS();
        }
 
        if (Z_TYPE_P(obj) == IS_STRING) {
@@ -156,7 +156,7 @@ PHP_FUNCTION(class_uses)
        }
        if (Z_TYPE_P(obj) != IS_OBJECT && Z_TYPE_P(obj) != IS_STRING) {
                zend_type_error("object or string expected");
-               return;
+               RETURN_THROWS();
        }
 
        if (Z_TYPE_P(obj) == IS_STRING) {
index 6c5d9251f2ae40ab6623eccb0a157c1bd9f3f76f..f8d4256aeed6a427741407aa26511c1d23735b6e 100644 (file)
@@ -1258,7 +1258,7 @@ PHP_FUNCTION(min)
 
                if (Z_TYPE(args[0]) != IS_ARRAY) {
                        zend_type_error("When only one parameter is given, it must be an array");
-                       return;
+                       RETURN_THROWS();
                } else {
                        if ((result = zend_hash_minmax(Z_ARRVAL(args[0]), php_array_data_compare, 0)) != NULL) {
                                ZVAL_COPY_DEREF(return_value, result);
@@ -1305,7 +1305,7 @@ PHP_FUNCTION(max)
 
                if (Z_TYPE(args[0]) != IS_ARRAY) {
                        zend_type_error("When only one parameter is given, it must be an array");
-                       return;
+                       RETURN_THROWS();
                } else {
                        if ((result = zend_hash_minmax(Z_ARRVAL(args[0]), php_array_data_compare, 1)) != NULL) {
                                ZVAL_COPY_DEREF(return_value, result);
@@ -3785,7 +3785,7 @@ static zend_always_inline void php_array_replace_wrapper(INTERNAL_FUNCTION_PARAM
 
                if (Z_TYPE_P(arg) != IS_ARRAY) {
                        zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(arg));
-                       return;
+                       RETURN_THROWS();
                }
        }
 
@@ -3829,7 +3829,7 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET
 
                if (Z_TYPE_P(arg) != IS_ARRAY) {
                        zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(arg));
-                       return;
+                       RETURN_THROWS();
                }
                count += zend_hash_num_elements(Z_ARRVAL_P(arg));
        }
@@ -4721,7 +4721,7 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa
        for (i = 0; i < argc; i++) {
                if (Z_TYPE(args[i]) != IS_ARRAY) {
                        zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
-                       return;
+                       RETURN_THROWS();
                }
        }
 
@@ -5126,7 +5126,7 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty
        for (i = 0; i < argc; i++) {
                if (Z_TYPE(args[i]) != IS_ARRAY) {
                        zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
-                       return;
+                       RETURN_THROWS();
                }
        }
 
@@ -5468,7 +5468,7 @@ PHP_FUNCTION(array_diff)
 
        if (Z_TYPE(args[0]) != IS_ARRAY) {
                zend_type_error("Expected parameter 1 to be an array, %s given", zend_zval_type_name(&args[0]));
-               return;
+               RETURN_THROWS();
        }
 
        num = zend_hash_num_elements(Z_ARRVAL(args[0]));
@@ -5476,7 +5476,7 @@ PHP_FUNCTION(array_diff)
                for (i = 1; i < argc; i++) {
                        if (Z_TYPE(args[i]) != IS_ARRAY) {
                                zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
-                               return;
+                               RETURN_THROWS();
                        }
                }
                RETURN_EMPTY_ARRAY();
@@ -5493,7 +5493,7 @@ PHP_FUNCTION(array_diff)
                        for (i = 1; i < argc; i++) {
                                if (Z_TYPE(args[i]) != IS_ARRAY) {
                                        zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
-                                       return;
+                                       RETURN_THROWS();
                                }
                        }
                        RETURN_EMPTY_ARRAY();
@@ -5504,7 +5504,7 @@ PHP_FUNCTION(array_diff)
                for (i = 1; i < argc; i++) {
                        if (Z_TYPE(args[i]) != IS_ARRAY) {
                                zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
-                               return;
+                               RETURN_THROWS();
                        }
                        if (!found) {
                                ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL(args[i]), value) {
@@ -5534,7 +5534,7 @@ PHP_FUNCTION(array_diff)
        for (i = 1; i < argc; i++) {
                if (Z_TYPE(args[i]) != IS_ARRAY) {
                        zend_type_error("Expected parameter %d to be an array, %s given", i + 1, zend_zval_type_name(&args[i]));
-                       return;
+                       RETURN_THROWS();
                }
                num += zend_hash_num_elements(Z_ARRVAL(args[i]));
        }
@@ -6186,7 +6186,7 @@ PHP_FUNCTION(array_map)
 
                if (Z_TYPE(arrays[0]) != IS_ARRAY) {
                        zend_type_error("Expected parameter 2 to be an array, %s given", zend_zval_type_name(&arrays[0]));
-                       return;
+                       RETURN_THROWS();
                }
                maxlen = zend_hash_num_elements(Z_ARRVAL(arrays[0]));
 
@@ -6228,7 +6228,7 @@ PHP_FUNCTION(array_map)
                        if (Z_TYPE(arrays[i]) != IS_ARRAY) {
                                zend_type_error("Expected parameter %d to be an array, %s given", i + 2, zend_zval_type_name(&arrays[i]));
                                efree(array_pos);
-                               return;
+                               RETURN_THROWS();
                        }
                        if (zend_hash_num_elements(Z_ARRVAL(arrays[i])) > maxlen) {
                                maxlen = zend_hash_num_elements(Z_ARRVAL(arrays[i]));
index 2f3edb9af3e083df9cf1eab371a5132e714ed716..59e31b5e6246d6894fd172db1c56cee94e719b01 100755 (executable)
@@ -3203,7 +3203,7 @@ PHP_FUNCTION(register_tick_function)
                efree(tick_fe.arguments);
                zend_type_error("Invalid tick callback '%s' passed", ZSTR_VAL(function_name));
                zend_string_release_ex(function_name, 0);
-               return;
+               RETURN_THROWS();
        } else if (function_name) {
                zend_string_release_ex(function_name, 0);
        }
index 36a5512b5da0db305dbcdfdf45882e3afc280ca1..2e4637e78c801cbbfa387f03ae5ca9aab7fe6be5 100644 (file)
@@ -260,7 +260,7 @@ PHP_FUNCTION(closedir)
 
        if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
                zend_type_error("%d is not a valid Directory resource", dirp->res->handle);
-               return;
+               RETURN_THROWS();
        }
 
        res = dirp->res;
@@ -374,7 +374,7 @@ PHP_FUNCTION(rewinddir)
 
        if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
                zend_type_error("%d is not a valid Directory resource", dirp->res->handle);
-               return;
+               RETURN_THROWS();
        }
 
        php_stream_rewinddir(dirp);
@@ -393,7 +393,7 @@ PHP_NAMED_FUNCTION(php_if_readdir)
 
        if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
                zend_type_error("%d is not a valid Directory resource", dirp->res->handle);
-               return;
+               RETURN_THROWS();
        }
 
        if (php_stream_readdir(dirp, &entry)) {
index 21ebba891dfae3b5bd096895b8846245edabfca9..4825fc02a5c546f7686acf5019a78d7e19a24959 100644 (file)
@@ -485,7 +485,7 @@ PHP_FUNCTION(escapeshellcmd)
        if (command_len) {
                if (command_len != strlen(command)) {
                        zend_type_error("Input string contains NULL bytes");
-                       return;
+                       RETURN_THROWS();
                }
                RETVAL_STR(php_escape_shell_cmd(command));
        } else {
@@ -507,7 +507,7 @@ PHP_FUNCTION(escapeshellarg)
 
        if (argument_len != strlen(argument)) {
                zend_type_error("Input string contains NULL bytes");
-               return;
+               RETURN_THROWS();
        }
 
        RETVAL_STR(php_escape_shell_arg(argument));
index 04f85d26770fe198eb4195647d649cbc45483ec7..6f521ed60cd0a40cafeb2cca51549ed3629b5b61 100644 (file)
@@ -354,7 +354,7 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
                                value = Z_STRVAL_P(group);
                        } else {
                                zend_type_error("Parameter 2 should be string or int, %s given", zend_zval_type_name(group));
-                               return;
+                               RETURN_THROWS();
                        }
                        if(wrapper->wops->stream_metadata(wrapper, filename, option, value, NULL)) {
                                RETURN_TRUE;
@@ -383,7 +383,7 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
                }
        } else {
                zend_type_error("Parameter 2 should be string or int, %s given", zend_zval_type_name(group));
-               return;
+               RETURN_THROWS();
        }
 
        /* Check the basedir */
index cc93849a1a88022f4d5321f7a28cea7d9f83bed0..31e9c141d8926b7871d9a65e825248c9b121b2d4 100644 (file)
@@ -969,7 +969,7 @@ PHP_FUNCTION(stream_context_get_options)
        context = decode_context_param(zcontext);
        if (!context) {
                zend_type_error("Invalid stream/context parameter");
-               return;
+               RETURN_THROWS();
        }
 
        ZVAL_COPY(return_value, &context->options);
@@ -994,7 +994,7 @@ PHP_FUNCTION(stream_context_set_option)
                /* figure out where the context is coming from exactly */
                if (!(context = decode_context_param(zcontext))) {
                        zend_type_error("Invalid stream/context parameter");
-                       return;
+                       RETURN_THROWS();
                }
 
                RETURN_BOOL(parse_context_options(context, options) == SUCCESS);
@@ -1013,7 +1013,7 @@ PHP_FUNCTION(stream_context_set_option)
                /* figure out where the context is coming from exactly */
                if (!(context = decode_context_param(zcontext))) {
                        zend_type_error("Invalid stream/context parameter");
-                       return;
+                       RETURN_THROWS();
                }
 
                RETURN_BOOL(php_stream_context_set_option(context, wrappername, optionname, zvalue) == SUCCESS);
@@ -1036,7 +1036,7 @@ PHP_FUNCTION(stream_context_set_params)
        context = decode_context_param(zcontext);
        if (!context) {
                zend_type_error("Invalid stream/context parameter");
-               return;
+               RETURN_THROWS();
        }
 
        RETVAL_BOOL(parse_context_params(context, params) == SUCCESS);
@@ -1057,7 +1057,7 @@ PHP_FUNCTION(stream_context_get_params)
        context = decode_context_param(zcontext);
        if (!context) {
                zend_type_error("Invalid stream/context parameter");
-               return;
+               RETURN_THROWS();
        }
 
        array_init(return_value);
@@ -1680,7 +1680,7 @@ PHP_FUNCTION(sapi_windows_vt100_support)
                        "%s() was not able to analyze the specified stream",
                        get_active_function_name()
                );
-               return;
+               RETURN_THROWS();
        }
 
        /* Check if the file descriptor is a console */
index f4c9bf55f1cb50cfaa84d7a8b15d6ab515f595ad..d2cc1bb4a1159fd1f60ee1341e16fd7c8e6beb14 100644 (file)
@@ -1277,7 +1277,7 @@ PHP_FUNCTION(implode)
        if (pieces == NULL) {
                if (arg1_array == NULL) {
                        zend_type_error("Argument must be an array");
-                       return;
+                       RETURN_THROWS();
                }
 
                arg1_str = ZSTR_EMPTY_ALLOC();
@@ -1285,7 +1285,7 @@ PHP_FUNCTION(implode)
        } else {
                if (arg1_str == NULL) {
                        zend_type_error("The first argument must be a string");
-                       return;
+                       RETURN_THROWS();
                }
        }
 
@@ -3251,10 +3251,10 @@ PHP_FUNCTION(strtr)
 
        if (ac == 2 && from_ht == NULL) {
                zend_type_error("If two arguments are passed, the second argument must be an array");
-               return;
+               RETURN_THROWS();
        } else if (ac != 2 && from_str == NULL) {
                zend_type_error("If three arguments are passed, the second argument must be a string");
-               return;
+               RETURN_THROWS();
        }
 
        /* shortcut for empty string */