]> granicus.if.org Git - php/commitdiff
Use RETURN_THROWS() after zend_value_error()
authorMáté Kocsis <kocsismate@woohoolabs.com>
Tue, 31 Dec 2019 15:58:15 +0000 (16:58 +0100)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Tue, 31 Dec 2019 15:58:15 +0000 (16:58 +0100)
ext/calendar/cal_unix.c
ext/calendar/calendar.c
ext/calendar/easter.c
ext/gd/gd.c
ext/json/json.c
ext/mbstring/mbstring.c
ext/sqlite3/sqlite3.c
ext/standard/array.c
ext/zip/php_zip.c

index c850bc1d5b7e7c5e58310c4a399a43d40d49ec48..f76fb908826fa2e7fd6c56118f8baf5ce676e07b 100644 (file)
@@ -36,7 +36,7 @@ PHP_FUNCTION(unixtojd)
                ts = time(NULL);
        } else if (ts < 0) {
                zend_value_error("timestamp must not be negative");
-               return;
+               RETURN_THROWS();
        }
 
        if (!(ta = php_localtime_r(&ts, &tmbuf))) {
@@ -60,7 +60,7 @@ PHP_FUNCTION(jdtounix)
 
        if (uday < 0 || uday > 24755) {
                zend_value_error("jday must be within the Unix epoch");
-               return;
+               RETURN_THROWS();
        }
 
        RETURN_LONG(uday * 24 * 3600);
index 570e004533e057266367b031129544be94d43d26..0254039a02b6ac9a6d7c0fcd8cda275b4266628e 100644 (file)
@@ -218,7 +218,7 @@ PHP_FUNCTION(cal_info)
 
        if (cal != -1 && (cal < 0 || cal >= CAL_NUM_CALS)) {
                zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
-               return;
+               RETURN_THROWS();
        }
 
        _php_cal_info(cal, return_value);
@@ -240,7 +240,7 @@ PHP_FUNCTION(cal_days_in_month)
 
        if (cal < 0 || cal >= CAL_NUM_CALS) {
                zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
-               return;
+               RETURN_THROWS();
        }
 
        calendar = &cal_conversion_table[cal];
@@ -249,7 +249,7 @@ PHP_FUNCTION(cal_days_in_month)
 
        if (sdn_start == 0) {
                zend_value_error("invalid date");
-               return;
+               RETURN_THROWS();
        }
 
        sdn_next = calendar->to_jd(year, 1 + month, 1);
@@ -286,7 +286,7 @@ PHP_FUNCTION(cal_to_jd)
 
        if (cal < 0 || cal >= CAL_NUM_CALS) {
                zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
-               return;
+               RETURN_THROWS();
        }
 
        RETURN_LONG(cal_conversion_table[cal].to_jd(year, month, day));
@@ -307,7 +307,7 @@ PHP_FUNCTION(cal_from_jd)
 
        if (cal < 0 || cal >= CAL_NUM_CALS) {
                zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
-               return;
+               RETURN_THROWS();
        }
        calendar = &cal_conversion_table[cal];
 
@@ -522,7 +522,7 @@ PHP_FUNCTION(jdtojewish)
        } else {
                if (year <= 0 || year > 9999) {
                        zend_value_error("Year out of range (0-9999)");
-                       return;
+                       RETURN_THROWS();
                }
 
                RETVAL_NEW_STR(zend_strpprintf(0, "%s %s %s", heb_number_to_chars(day, fl, &dayp), JEWISH_HEB_MONTH_NAME(year)[month], heb_number_to_chars(year, fl, &yearp)));
index 4bb8c6e3b08368b8040dded28c3b1e8e7bf6b8ef..98087d318cd70c9c392dea69d69048f3b3013ae2 100644 (file)
@@ -50,7 +50,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, zend_long gm)
 
        if (gm && (year<1970 || year>2037)) {                           /* out of range for timestamps */
                zend_value_error("This function is only valid for years between 1970 and 2037 inclusive");
-               return;
+               RETURN_THROWS();
        }
 
        golden = (year % 19) + 1;                                       /* the Golden number */
index 129bd89bb26a947aa29525427b598b4fd11ea635..60c38b620708081751e61044d66d661326032d5c 100644 (file)
@@ -886,7 +886,7 @@ PHP_FUNCTION(imagesetstyle)
        num_styles = zend_hash_num_elements(Z_ARRVAL_P(styles));
        if (num_styles == 0) {
                zend_value_error("Styles array must not be empty");
-               return;
+               RETURN_THROWS();
        }
 
        /* copy the style values in the stylearr */
@@ -917,12 +917,12 @@ PHP_FUNCTION(imagecreatetruecolor)
 
        if (x_size <= 0 || x_size >= INT_MAX) {
                zend_value_error("Invalid width (x_size)");
-               return;
+               RETURN_THROWS();
        }
 
        if (y_size <= 0 || y_size >= INT_MAX) {
                zend_value_error("Invalid height (y_size)");
-               return;
+               RETURN_THROWS();
        }
 
        im = gdImageCreateTrueColor(x_size, y_size);
@@ -969,7 +969,7 @@ PHP_FUNCTION(imagetruecolortopalette)
 
        if (ncolors <= 0 || ZEND_LONG_INT_OVFL(ncolors)) {
                zend_value_error("Number of colors has to be greater than zero and no more than %d", INT_MAX);
-               return;
+               RETURN_THROWS();
        }
 
        if (gdImageTrueColorToPalette(im, dither, (int)ncolors)) {
@@ -1174,7 +1174,7 @@ PHP_FUNCTION(imagelayereffect)
 #define CHECK_RGBA_RANGE(component, name) \
        if (component < 0 || component > gd##name##Max) { \
                zend_value_error(#name " component is out of range, must be between 0 and %d (inclusive)", gd##name##Max); \
-               return; \
+               RETURN_THROWS(); \
        }
 
 /* {{{ proto int imagecolorallocatealpha(resource im, int red, int green, int blue, int alpha)
@@ -1512,12 +1512,12 @@ PHP_FUNCTION(imagecreate)
 
        if (x_size <= 0 || x_size >= INT_MAX) {
                zend_value_error("Invalid width (x_size)");
-               return;
+               RETURN_THROWS();
        }
 
        if (y_size <= 0 || y_size >= INT_MAX) {
                zend_value_error("Invalid height (y_size)");
-               return;
+               RETURN_THROWS();
        }
 
        im = gdImageCreate(x_size, y_size);
@@ -1751,12 +1751,12 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
 
                if (width < 1) {
                        zend_value_error("Width must be at least 1");
-                       return;
+                       RETURN_THROWS();
                }
 
                if (height < 1) {
                        zend_value_error("Height must be at least 1");
-                       return;
+                       RETURN_THROWS();
                }
 
        } else {
@@ -2307,7 +2307,7 @@ PHP_FUNCTION(imagecolordeallocate)
                RETURN_TRUE;
        } else {
                zend_value_error("Color index %d out of range", col);
-               return;
+               RETURN_THROWS();
        }
 }
 /* }}} */
@@ -2435,7 +2435,7 @@ PHP_FUNCTION(imagegammacorrect)
 
        if ( input <= 0.0 || output <= 0.0 ) {
                zend_value_error("Gamma values must be positive");
-               return;
+               RETURN_THROWS();
        }
 
        gamma = input / output;
@@ -2744,7 +2744,7 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
                NPOINTS = zend_hash_num_elements(Z_ARRVAL_P(POINTS));
                if (NPOINTS % 2 != 0) {
                        zend_value_error("Points array must have an even number of elements");
-                       return;
+                       RETURN_THROWS();
                }
                NPOINTS /= 2;
        }
@@ -2757,12 +2757,12 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
        nelem = zend_hash_num_elements(Z_ARRVAL_P(POINTS));
        if (npoints < 3) {
                zend_value_error("Polygon must have at least 3 points");
-               return;
+               RETURN_THROWS();
        }
 
        if (nelem < npoints * 2) {
                zend_value_error("Trying to use %d points in array with only %d points", npoints, nelem/2);
-               return;
+               RETURN_THROWS();
        }
 
        points = (gdPointPtr) safe_emalloc(npoints, sizeof(gdPoint), 0);
@@ -3134,7 +3134,7 @@ PHP_FUNCTION(imagecopyresized)
 
        if (dstW <= 0 || dstH <= 0 || srcW <= 0 || srcH <= 0) {
                zend_value_error("Invalid image dimensions");
-               return;
+               RETURN_THROWS();
        }
 
        gdImageCopyResized(im_dst, im_src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
@@ -3616,14 +3616,14 @@ PHP_FUNCTION(imageconvolution)
        nelem = zend_hash_num_elements(Z_ARRVAL_P(hash_matrix));
        if (nelem != 3) {
                zend_value_error("Convolution matrix must be a 3x3 array");
-               return;
+               RETURN_THROWS();
        }
 
        for (i=0; i<3; i++) {
                if ((var = zend_hash_index_find(Z_ARRVAL_P(hash_matrix), (i))) != NULL && Z_TYPE_P(var) == IS_ARRAY) {
                        if (zend_hash_num_elements(Z_ARRVAL_P(var)) != 3 ) {
                                zend_value_error("Convolution matrix must be a 3x3 array, matrix[%d] only has %d elements", i, zend_hash_num_elements(Z_ARRVAL_P(var)));
-                               return;
+                               RETURN_THROWS();
                        }
 
                        for (j=0; j<3; j++) {
@@ -3631,7 +3631,7 @@ PHP_FUNCTION(imageconvolution)
                                        matrix[i][j] = (float) zval_get_double(var2);
                                } else {
                                        zend_value_error("Convolution matrix must be a 3x3 array, matrix[%d][%d] cannot be found (missing integer key)", i, j);
-                                       return;
+                                       RETURN_THROWS();
                                }
                        }
                }
@@ -3676,7 +3676,7 @@ PHP_FUNCTION(imageflip)
 
                default:
                        zend_value_error("Unknown flip mode");
-                       return;
+                       RETURN_THROWS();
        }
 
        RETURN_TRUE;
@@ -3725,28 +3725,28 @@ PHP_FUNCTION(imagecrop)
                rect.x = zval_get_long(tmp);
        } else {
                zend_value_error("Cropping rectangle is missing x position");
-               return;
+               RETURN_THROWS();
        }
 
        if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "y", sizeof("y") - 1)) != NULL) {
                rect.y = zval_get_long(tmp);
        } else {
                zend_value_error("Cropping rectangle is missing y position");
-               return;
+               RETURN_THROWS();
        }
 
        if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "width", sizeof("width") - 1)) != NULL) {
                rect.width = zval_get_long(tmp);
        } else {
                zend_value_error("Cropping rectangle is missing width");
-               return;
+               RETURN_THROWS();
        }
 
        if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "height", sizeof("height") - 1)) != NULL) {
                rect.height = zval_get_long(tmp);
        } else {
                zend_value_error("Cropping rectangle is missing height");
-               return;
+               RETURN_THROWS();
        }
 
        im_crop = gdImageCrop(im, &rect);
@@ -3788,14 +3788,14 @@ PHP_FUNCTION(imagecropauto)
                case GD_CROP_THRESHOLD:
                        if (color < 0 || (!gdImageTrueColor(im) && color >= gdImageColorsTotal(im))) {
                                zend_value_error("Color argument missing with threshold mode");
-                               return;
+                               RETURN_THROWS();
                        }
                        im_crop = gdImageCropThreshold(im, color, (float) threshold);
                        break;
 
                default:
                        zend_value_error("Unknown crop mode");
-                       return;
+                       RETURN_THROWS();
        }
 
        if (im_crop == NULL) {
@@ -3885,7 +3885,7 @@ PHP_FUNCTION(imageaffine)
 
        if ((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_affine))) != 6) {
                zend_value_error("Affine array must have six elements");
-               return;
+               RETURN_THROWS();
        }
 
        for (i = 0; i < nelems; i++) {
@@ -3912,28 +3912,28 @@ PHP_FUNCTION(imageaffine)
                        rect.x = zval_get_long(tmp);
                } else {
                        zend_value_error("Clip array is missing x position");
-                       return;
+                       RETURN_THROWS();
                }
 
                if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "y", sizeof("y") - 1)) != NULL) {
                        rect.y = zval_get_long(tmp);
                } else {
                        zend_value_error("Clip array is missing y position");
-                       return;
+                       RETURN_THROWS();
                }
 
                if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "width", sizeof("width") - 1)) != NULL) {
                        rect.width = zval_get_long(tmp);
                } else {
                        zend_value_error("Clip array is missing width");
-                       return;
+                       RETURN_THROWS();
                }
 
                if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "height", sizeof("height") - 1)) != NULL) {
                        rect.height = zval_get_long(tmp);
                } else {
                        zend_value_error("Clip array is missing height");
-                       return;
+                       RETURN_THROWS();
                }
                pRect = &rect;
        } else {
@@ -3983,14 +3983,14 @@ PHP_FUNCTION(imageaffinematrixget)
                                x = zval_get_double(tmp);
                        } else {
                                zend_value_error("Options array is missing x position");
-                               return;
+                               RETURN_THROWS();
                        }
 
                        if ((tmp = zend_hash_str_find(Z_ARRVAL_P(options), "y", sizeof("y") - 1)) != NULL) {
                                y = zval_get_double(tmp);
                        } else {
                                zend_value_error("Options array is missing y position");
-                               return;
+                               RETURN_THROWS();
                        }
 
                        if (type == GD_AFFINE_TRANSLATE) {
@@ -4025,7 +4025,7 @@ PHP_FUNCTION(imageaffinematrixget)
 
                default:
                        zend_value_error("Invalid type for element " ZEND_LONG_FMT, type);
-                       return;
+                       RETURN_THROWS();
        }
 
        if (res == GD_FALSE) {
@@ -4057,7 +4057,7 @@ PHP_FUNCTION(imageaffinematrixconcat)
 
        if (((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_m1))) != 6) || (nelems = zend_hash_num_elements(Z_ARRVAL_P(z_m2))) != 6) {
                zend_value_error("Affine arrays must have six elements");
-               return;
+               RETURN_THROWS();
        }
 
        for (i = 0; i < 6; i++) {
index 9a8f259f013c817a1225eafa007b23eaa93cd75f..4645309741175bcf3da5dacf2808cf6681ec1c61 100644 (file)
@@ -314,12 +314,12 @@ static PHP_FUNCTION(json_decode)
 
        if (depth <= 0) {
                zend_value_error("Depth must be greater than zero");
-               return;
+               RETURN_THROWS();
        }
 
        if (depth > INT_MAX) {
                zend_value_error("Depth must be lower than %d", INT_MAX);
-               return;
+               RETURN_THROWS();
        }
 
        /* For BC reasons, the bool $assoc overrides the long $options bit for PHP_JSON_OBJECT_AS_ARRAY */
index 115af92fc2d701ec8987357ca9b177f37cfa3d96..37e7e6b7a9e469f5589ecec880152a1f2bb47a43 100644 (file)
@@ -3636,7 +3636,7 @@ php_mb_numericentity_exec(INTERNAL_FUNCTION_PARAMETERS, int type)
        i = zend_hash_num_elements(target_hash);
        if (i % 4 != 0) {
                zend_value_error("count($convmap) must be a multiple of 4");
-               return;
+               RETURN_THROWS();
        }
        convmap = (int *)safe_emalloc(i, sizeof(int), 0);
        mapelm = convmap;
index f35e11f01da08a9d3847be821e805bb32b9f88da..3f4bba21919642dca3a0647559d98ffbe2622d0f 100644 (file)
@@ -1300,7 +1300,7 @@ PHP_METHOD(sqlite3, openBlob)
 
        if (ZEND_NUM_ARGS() >= 4 && CHECK_NULL_PATH(dbname, dbname_len)) {
                zend_value_error("dbname must not contain NUL bytes");
-               return;
+               RETURN_THROWS();
        }
 
        sqlite_flags = (flags & SQLITE_OPEN_READWRITE) ? 1 : 0;
@@ -1409,7 +1409,7 @@ PHP_METHOD(sqlite3, backup)
                || (ZEND_NUM_ARGS() >= 3 && CHECK_NULL_PATH(destination_dbname, destination_dbname_length))
        ) {
                zend_value_error("dbname must not contain NUL bytes");
-               return;
+               RETURN_THROWS();
        }
 
        destination_obj = Z_SQLITE3_DB_P(destination_zval);
index 4056ff60ad6441c87d6a97eca1bbe70f7dedee0f..6c5d9251f2ae40ab6623eccb0a157c1bd9f3f76f 100644 (file)
@@ -6385,7 +6385,7 @@ PHP_FUNCTION(array_chunk)
        /* Do bounds checking for size parameter. */
        if (size < 1) {
                zend_value_error("Size parameter expected to be greater than 0");
-               return;
+               RETURN_THROWS();
        }
 
        num_in = zend_hash_num_elements(Z_ARRVAL_P(input));
@@ -6454,7 +6454,7 @@ PHP_FUNCTION(array_combine)
 
        if (num_keys != num_values) {
                zend_value_error("Both parameters should have an equal number of elements");
-               return;
+               RETURN_THROWS();
        }
 
        if (!num_keys) {
index 776b4338506af005e525c3c4fd70cc3c110345a3..aca478a7804a73dbb5a9868c16b918f375fe4a4c 100644 (file)
@@ -373,7 +373,7 @@ static int php_zip_parse_options(zval *options, zend_long *remove_all_path, char
                intern = obj->za; \
                if (!intern) { \
                        zend_value_error("Invalid or uninitialized Zip object"); \
-                       return; \
+                       RETURN_THROWS(); \
                } \
        }
 /* }}} */