Skip to content

Commit 12ce73a

Browse files
committed
Use RETURN_THROWS() after zend_value_error()
1 parent 8176059 commit 12ce73a

File tree

9 files changed

+51
-51
lines changed

9 files changed

+51
-51
lines changed

ext/calendar/cal_unix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PHP_FUNCTION(unixtojd)
3636
ts = time(NULL);
3737
} else if (ts < 0) {
3838
zend_value_error("timestamp must not be negative");
39-
return;
39+
RETURN_THROWS();
4040
}
4141

4242
if (!(ta = php_localtime_r(&ts, &tmbuf))) {
@@ -60,7 +60,7 @@ PHP_FUNCTION(jdtounix)
6060

6161
if (uday < 0 || uday > 24755) {
6262
zend_value_error("jday must be within the Unix epoch");
63-
return;
63+
RETURN_THROWS();
6464
}
6565

6666
RETURN_LONG(uday * 24 * 3600);

ext/calendar/calendar.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ PHP_FUNCTION(cal_info)
218218

219219
if (cal != -1 && (cal < 0 || cal >= CAL_NUM_CALS)) {
220220
zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
221-
return;
221+
RETURN_THROWS();
222222
}
223223

224224
_php_cal_info(cal, return_value);
@@ -240,7 +240,7 @@ PHP_FUNCTION(cal_days_in_month)
240240

241241
if (cal < 0 || cal >= CAL_NUM_CALS) {
242242
zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
243-
return;
243+
RETURN_THROWS();
244244
}
245245

246246
calendar = &cal_conversion_table[cal];
@@ -249,7 +249,7 @@ PHP_FUNCTION(cal_days_in_month)
249249

250250
if (sdn_start == 0) {
251251
zend_value_error("invalid date");
252-
return;
252+
RETURN_THROWS();
253253
}
254254

255255
sdn_next = calendar->to_jd(year, 1 + month, 1);
@@ -286,7 +286,7 @@ PHP_FUNCTION(cal_to_jd)
286286

287287
if (cal < 0 || cal >= CAL_NUM_CALS) {
288288
zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
289-
return;
289+
RETURN_THROWS();
290290
}
291291

292292
RETURN_LONG(cal_conversion_table[cal].to_jd(year, month, day));
@@ -307,7 +307,7 @@ PHP_FUNCTION(cal_from_jd)
307307

308308
if (cal < 0 || cal >= CAL_NUM_CALS) {
309309
zend_value_error("invalid calendar ID " ZEND_LONG_FMT, cal);
310-
return;
310+
RETURN_THROWS();
311311
}
312312
calendar = &cal_conversion_table[cal];
313313

@@ -522,7 +522,7 @@ PHP_FUNCTION(jdtojewish)
522522
} else {
523523
if (year <= 0 || year > 9999) {
524524
zend_value_error("Year out of range (0-9999)");
525-
return;
525+
RETURN_THROWS();
526526
}
527527

528528
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)));

ext/calendar/easter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, zend_long gm)
5050

5151
if (gm && (year<1970 || year>2037)) { /* out of range for timestamps */
5252
zend_value_error("This function is only valid for years between 1970 and 2037 inclusive");
53-
return;
53+
RETURN_THROWS();
5454
}
5555

5656
golden = (year % 19) + 1; /* the Golden number */

ext/gd/gd.c

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ PHP_FUNCTION(imagesetstyle)
886886
num_styles = zend_hash_num_elements(Z_ARRVAL_P(styles));
887887
if (num_styles == 0) {
888888
zend_value_error("Styles array must not be empty");
889-
return;
889+
RETURN_THROWS();
890890
}
891891

892892
/* copy the style values in the stylearr */
@@ -917,12 +917,12 @@ PHP_FUNCTION(imagecreatetruecolor)
917917

918918
if (x_size <= 0 || x_size >= INT_MAX) {
919919
zend_value_error("Invalid width (x_size)");
920-
return;
920+
RETURN_THROWS();
921921
}
922922

923923
if (y_size <= 0 || y_size >= INT_MAX) {
924924
zend_value_error("Invalid height (y_size)");
925-
return;
925+
RETURN_THROWS();
926926
}
927927

928928
im = gdImageCreateTrueColor(x_size, y_size);
@@ -969,7 +969,7 @@ PHP_FUNCTION(imagetruecolortopalette)
969969

970970
if (ncolors <= 0 || ZEND_LONG_INT_OVFL(ncolors)) {
971971
zend_value_error("Number of colors has to be greater than zero and no more than %d", INT_MAX);
972-
return;
972+
RETURN_THROWS();
973973
}
974974

975975
if (gdImageTrueColorToPalette(im, dither, (int)ncolors)) {
@@ -1174,7 +1174,7 @@ PHP_FUNCTION(imagelayereffect)
11741174
#define CHECK_RGBA_RANGE(component, name) \
11751175
if (component < 0 || component > gd##name##Max) { \
11761176
zend_value_error(#name " component is out of range, must be between 0 and %d (inclusive)", gd##name##Max); \
1177-
return; \
1177+
RETURN_THROWS(); \
11781178
}
11791179

11801180
/* {{{ proto int imagecolorallocatealpha(resource im, int red, int green, int blue, int alpha)
@@ -1512,12 +1512,12 @@ PHP_FUNCTION(imagecreate)
15121512

15131513
if (x_size <= 0 || x_size >= INT_MAX) {
15141514
zend_value_error("Invalid width (x_size)");
1515-
return;
1515+
RETURN_THROWS();
15161516
}
15171517

15181518
if (y_size <= 0 || y_size >= INT_MAX) {
15191519
zend_value_error("Invalid height (y_size)");
1520-
return;
1520+
RETURN_THROWS();
15211521
}
15221522

15231523
im = gdImageCreate(x_size, y_size);
@@ -1751,12 +1751,12 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
17511751

17521752
if (width < 1) {
17531753
zend_value_error("Width must be at least 1");
1754-
return;
1754+
RETURN_THROWS();
17551755
}
17561756

17571757
if (height < 1) {
17581758
zend_value_error("Height must be at least 1");
1759-
return;
1759+
RETURN_THROWS();
17601760
}
17611761

17621762
} else {
@@ -2307,7 +2307,7 @@ PHP_FUNCTION(imagecolordeallocate)
23072307
RETURN_TRUE;
23082308
} else {
23092309
zend_value_error("Color index %d out of range", col);
2310-
return;
2310+
RETURN_THROWS();
23112311
}
23122312
}
23132313
/* }}} */
@@ -2435,7 +2435,7 @@ PHP_FUNCTION(imagegammacorrect)
24352435

24362436
if ( input <= 0.0 || output <= 0.0 ) {
24372437
zend_value_error("Gamma values must be positive");
2438-
return;
2438+
RETURN_THROWS();
24392439
}
24402440

24412441
gamma = input / output;
@@ -2744,7 +2744,7 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
27442744
NPOINTS = zend_hash_num_elements(Z_ARRVAL_P(POINTS));
27452745
if (NPOINTS % 2 != 0) {
27462746
zend_value_error("Points array must have an even number of elements");
2747-
return;
2747+
RETURN_THROWS();
27482748
}
27492749
NPOINTS /= 2;
27502750
}
@@ -2757,12 +2757,12 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
27572757
nelem = zend_hash_num_elements(Z_ARRVAL_P(POINTS));
27582758
if (npoints < 3) {
27592759
zend_value_error("Polygon must have at least 3 points");
2760-
return;
2760+
RETURN_THROWS();
27612761
}
27622762

27632763
if (nelem < npoints * 2) {
27642764
zend_value_error("Trying to use %d points in array with only %d points", npoints, nelem/2);
2765-
return;
2765+
RETURN_THROWS();
27662766
}
27672767

27682768
points = (gdPointPtr) safe_emalloc(npoints, sizeof(gdPoint), 0);
@@ -3134,7 +3134,7 @@ PHP_FUNCTION(imagecopyresized)
31343134

31353135
if (dstW <= 0 || dstH <= 0 || srcW <= 0 || srcH <= 0) {
31363136
zend_value_error("Invalid image dimensions");
3137-
return;
3137+
RETURN_THROWS();
31383138
}
31393139

31403140
gdImageCopyResized(im_dst, im_src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
@@ -3616,22 +3616,22 @@ PHP_FUNCTION(imageconvolution)
36163616
nelem = zend_hash_num_elements(Z_ARRVAL_P(hash_matrix));
36173617
if (nelem != 3) {
36183618
zend_value_error("Convolution matrix must be a 3x3 array");
3619-
return;
3619+
RETURN_THROWS();
36203620
}
36213621

36223622
for (i=0; i<3; i++) {
36233623
if ((var = zend_hash_index_find(Z_ARRVAL_P(hash_matrix), (i))) != NULL && Z_TYPE_P(var) == IS_ARRAY) {
36243624
if (zend_hash_num_elements(Z_ARRVAL_P(var)) != 3 ) {
36253625
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)));
3626-
return;
3626+
RETURN_THROWS();
36273627
}
36283628

36293629
for (j=0; j<3; j++) {
36303630
if ((var2 = zend_hash_index_find(Z_ARRVAL_P(var), j)) != NULL) {
36313631
matrix[i][j] = (float) zval_get_double(var2);
36323632
} else {
36333633
zend_value_error("Convolution matrix must be a 3x3 array, matrix[%d][%d] cannot be found (missing integer key)", i, j);
3634-
return;
3634+
RETURN_THROWS();
36353635
}
36363636
}
36373637
}
@@ -3676,7 +3676,7 @@ PHP_FUNCTION(imageflip)
36763676

36773677
default:
36783678
zend_value_error("Unknown flip mode");
3679-
return;
3679+
RETURN_THROWS();
36803680
}
36813681

36823682
RETURN_TRUE;
@@ -3725,28 +3725,28 @@ PHP_FUNCTION(imagecrop)
37253725
rect.x = zval_get_long(tmp);
37263726
} else {
37273727
zend_value_error("Cropping rectangle is missing x position");
3728-
return;
3728+
RETURN_THROWS();
37293729
}
37303730

37313731
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "y", sizeof("y") - 1)) != NULL) {
37323732
rect.y = zval_get_long(tmp);
37333733
} else {
37343734
zend_value_error("Cropping rectangle is missing y position");
3735-
return;
3735+
RETURN_THROWS();
37363736
}
37373737

37383738
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "width", sizeof("width") - 1)) != NULL) {
37393739
rect.width = zval_get_long(tmp);
37403740
} else {
37413741
zend_value_error("Cropping rectangle is missing width");
3742-
return;
3742+
RETURN_THROWS();
37433743
}
37443744

37453745
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "height", sizeof("height") - 1)) != NULL) {
37463746
rect.height = zval_get_long(tmp);
37473747
} else {
37483748
zend_value_error("Cropping rectangle is missing height");
3749-
return;
3749+
RETURN_THROWS();
37503750
}
37513751

37523752
im_crop = gdImageCrop(im, &rect);
@@ -3788,14 +3788,14 @@ PHP_FUNCTION(imagecropauto)
37883788
case GD_CROP_THRESHOLD:
37893789
if (color < 0 || (!gdImageTrueColor(im) && color >= gdImageColorsTotal(im))) {
37903790
zend_value_error("Color argument missing with threshold mode");
3791-
return;
3791+
RETURN_THROWS();
37923792
}
37933793
im_crop = gdImageCropThreshold(im, color, (float) threshold);
37943794
break;
37953795

37963796
default:
37973797
zend_value_error("Unknown crop mode");
3798-
return;
3798+
RETURN_THROWS();
37993799
}
38003800

38013801
if (im_crop == NULL) {
@@ -3885,7 +3885,7 @@ PHP_FUNCTION(imageaffine)
38853885

38863886
if ((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_affine))) != 6) {
38873887
zend_value_error("Affine array must have six elements");
3888-
return;
3888+
RETURN_THROWS();
38893889
}
38903890

38913891
for (i = 0; i < nelems; i++) {
@@ -3912,28 +3912,28 @@ PHP_FUNCTION(imageaffine)
39123912
rect.x = zval_get_long(tmp);
39133913
} else {
39143914
zend_value_error("Clip array is missing x position");
3915-
return;
3915+
RETURN_THROWS();
39163916
}
39173917

39183918
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "y", sizeof("y") - 1)) != NULL) {
39193919
rect.y = zval_get_long(tmp);
39203920
} else {
39213921
zend_value_error("Clip array is missing y position");
3922-
return;
3922+
RETURN_THROWS();
39233923
}
39243924

39253925
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "width", sizeof("width") - 1)) != NULL) {
39263926
rect.width = zval_get_long(tmp);
39273927
} else {
39283928
zend_value_error("Clip array is missing width");
3929-
return;
3929+
RETURN_THROWS();
39303930
}
39313931

39323932
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "height", sizeof("height") - 1)) != NULL) {
39333933
rect.height = zval_get_long(tmp);
39343934
} else {
39353935
zend_value_error("Clip array is missing height");
3936-
return;
3936+
RETURN_THROWS();
39373937
}
39383938
pRect = &rect;
39393939
} else {
@@ -3983,14 +3983,14 @@ PHP_FUNCTION(imageaffinematrixget)
39833983
x = zval_get_double(tmp);
39843984
} else {
39853985
zend_value_error("Options array is missing x position");
3986-
return;
3986+
RETURN_THROWS();
39873987
}
39883988

39893989
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(options), "y", sizeof("y") - 1)) != NULL) {
39903990
y = zval_get_double(tmp);
39913991
} else {
39923992
zend_value_error("Options array is missing y position");
3993-
return;
3993+
RETURN_THROWS();
39943994
}
39953995

39963996
if (type == GD_AFFINE_TRANSLATE) {
@@ -4025,7 +4025,7 @@ PHP_FUNCTION(imageaffinematrixget)
40254025

40264026
default:
40274027
zend_value_error("Invalid type for element " ZEND_LONG_FMT, type);
4028-
return;
4028+
RETURN_THROWS();
40294029
}
40304030

40314031
if (res == GD_FALSE) {
@@ -4057,7 +4057,7 @@ PHP_FUNCTION(imageaffinematrixconcat)
40574057

40584058
if (((nelems = zend_hash_num_elements(Z_ARRVAL_P(z_m1))) != 6) || (nelems = zend_hash_num_elements(Z_ARRVAL_P(z_m2))) != 6) {
40594059
zend_value_error("Affine arrays must have six elements");
4060-
return;
4060+
RETURN_THROWS();
40614061
}
40624062

40634063
for (i = 0; i < 6; i++) {

ext/json/json.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,12 @@ static PHP_FUNCTION(json_decode)
314314

315315
if (depth <= 0) {
316316
zend_value_error("Depth must be greater than zero");
317-
return;
317+
RETURN_THROWS();
318318
}
319319

320320
if (depth > INT_MAX) {
321321
zend_value_error("Depth must be lower than %d", INT_MAX);
322-
return;
322+
RETURN_THROWS();
323323
}
324324

325325
/* For BC reasons, the bool $assoc overrides the long $options bit for PHP_JSON_OBJECT_AS_ARRAY */

ext/mbstring/mbstring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3636,7 +3636,7 @@ php_mb_numericentity_exec(INTERNAL_FUNCTION_PARAMETERS, int type)
36363636
i = zend_hash_num_elements(target_hash);
36373637
if (i % 4 != 0) {
36383638
zend_value_error("count($convmap) must be a multiple of 4");
3639-
return;
3639+
RETURN_THROWS();
36403640
}
36413641
convmap = (int *)safe_emalloc(i, sizeof(int), 0);
36423642
mapelm = convmap;

0 commit comments

Comments
 (0)