Skip to content

Commit a20c9bd

Browse files
committed
made scale argument of bcmath functions non-negative integer
1 parent 5fddc27 commit a20c9bd

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

ext/bcmath/bcmath.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ PHP_FUNCTION(bcadd)
153153

154154
if (ZEND_NUM_ARGS() == 3) {
155155
if (scale_param < 0 || scale_param > INT_MAX) {
156-
zend_argument_value_error(3, "must be greater than or equal to 0 and less than INT_MAX (%d)", INT_MAX);
156+
zend_argument_value_error(3, "must be between 0 and %d", INT_MAX);
157157
RETURN_THROWS();
158158
}
159159
scale = (int) scale_param;
@@ -192,7 +192,7 @@ PHP_FUNCTION(bcsub)
192192

193193
if (ZEND_NUM_ARGS() == 3) {
194194
if (scale_param < 0 || scale_param > INT_MAX) {
195-
zend_argument_value_error(3, "must be greater than or equal to 0 and less than INT_MAX (%d)", INT_MAX);
195+
zend_argument_value_error(3, "must be between 0 and %d", INT_MAX);
196196
RETURN_THROWS();
197197
}
198198
scale = (int) scale_param;
@@ -231,7 +231,7 @@ PHP_FUNCTION(bcmul)
231231

232232
if (ZEND_NUM_ARGS() == 3) {
233233
if (scale_param < 0 || scale_param > INT_MAX) {
234-
zend_argument_value_error(3, "must be greater than or equal to 0 and less than INT_MAX (%d)", INT_MAX);
234+
zend_argument_value_error(3, "must be between 0 and %d", INT_MAX);
235235
RETURN_THROWS();
236236
}
237237
scale = (int) scale_param;
@@ -270,7 +270,7 @@ PHP_FUNCTION(bcdiv)
270270

271271
if (ZEND_NUM_ARGS() == 3) {
272272
if (scale_param < 0 || scale_param > INT_MAX) {
273-
zend_argument_value_error(3, "must be greater than or equal to 0 and less than INT_MAX (%d)", INT_MAX);
273+
zend_argument_value_error(3, "must be between 0 and %d", INT_MAX);
274274
RETURN_THROWS();
275275
}
276276
scale = (int) scale_param;
@@ -316,7 +316,7 @@ PHP_FUNCTION(bcmod)
316316

317317
if (ZEND_NUM_ARGS() == 3) {
318318
if (scale_param < 0 || scale_param > INT_MAX) {
319-
zend_argument_value_error(3, "must be greater than or equal to 0 and less than INT_MAX (%d)", INT_MAX);
319+
zend_argument_value_error(3, "must be between 0 and %d", INT_MAX);
320320
RETURN_THROWS();
321321
}
322322
scale = (int) scale_param;
@@ -371,7 +371,7 @@ PHP_FUNCTION(bcpowmod)
371371

372372
if (ZEND_NUM_ARGS() == 4) {
373373
if (scale_param < 0 || scale_param > INT_MAX) {
374-
zend_argument_value_error(4, "must be greater than or equal to 0 and less than INT_MAX (%d)", INT_MAX);
374+
zend_argument_value_error(4, "must be between 0 and %d", INT_MAX);
375375
RETURN_THROWS();
376376
}
377377
scale = (int) scale_param;
@@ -409,7 +409,7 @@ PHP_FUNCTION(bcpow)
409409

410410
if (ZEND_NUM_ARGS() == 3) {
411411
if (scale_param < 0 || scale_param > INT_MAX) {
412-
zend_argument_value_error(3, "must be greater than or equal to 0 and less than INT_MAX (%d)", INT_MAX);
412+
zend_argument_value_error(3, "must be between 0 and %d", INT_MAX);
413413
RETURN_THROWS();
414414
}
415415
scale = (int) scale_param;
@@ -447,7 +447,7 @@ PHP_FUNCTION(bcsqrt)
447447

448448
if (ZEND_NUM_ARGS() == 2) {
449449
if (scale_param < 0 || scale_param > INT_MAX) {
450-
zend_argument_value_error(2, "must be greater than or equal to 0 and less than INT_MAX (%d)", INT_MAX);
450+
zend_argument_value_error(2, "must be between 0 and %d", INT_MAX);
451451
RETURN_THROWS();
452452
}
453453
scale = (int) scale_param;
@@ -485,7 +485,7 @@ PHP_FUNCTION(bccomp)
485485

486486
if (ZEND_NUM_ARGS() == 3) {
487487
if (scale_param < 0 || scale_param > INT_MAX) {
488-
zend_argument_value_error(3, "must be greater than or equal to 0 and less than INT_MAX (%d)", INT_MAX);
488+
zend_argument_value_error(3, "must be between 0 and %d", INT_MAX);
489489
RETURN_THROWS();
490490
}
491491
scale = (int) scale_param;
@@ -523,7 +523,7 @@ PHP_FUNCTION(bcscale)
523523

524524
if (ZEND_NUM_ARGS() == 1) {
525525
if (new_scale < 0 || new_scale > INT_MAX) {
526-
zend_argument_value_error(1, "must be greater than or equal to 0 and less than INT_MAX (%d)", INT_MAX);
526+
zend_argument_value_error(1, "must be between 0 and %d", INT_MAX);
527527
RETURN_THROWS();
528528
}
529529
BCG(bc_precision) = (int) new_scale;

ext/bcmath/tests/bcscale_variation001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ try {
1515
?>
1616
--EXPECT--
1717
5
18-
bcscale(): Argument #1 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
18+
bcscale(): Argument #1 ($scale) must be between 0 and 2147483647

ext/bcmath/tests/bug60377.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ $var414 = bcadd(0,-1,10);
1515
?>
1616

1717
--EXPECT--
18-
bcscale(): Argument #1 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
18+
bcscale(): Argument #1 ($scale) must be between 0 and 2147483647

ext/bcmath/tests/bug72093.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ try {
1414
var_dump(bcpowmod(1, 1.2, 1, 1));
1515
?>
1616
--EXPECTF--
17-
bcpowmod(): Argument #4 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
17+
bcpowmod(): Argument #4 ($scale) must be between 0 and 2147483647
1818

1919
Warning: bcpowmod(): Non-zero scale in exponent in %s on line %d
2020
string(3) "0.0"

ext/bcmath/tests/negative_scale.phpt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ try {
5858
}
5959
?>
6060
--EXPECT--
61-
bcadd(): Argument #3 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
62-
bcsub(): Argument #3 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
63-
bcmul(): Argument #3 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
64-
bcdiv(): Argument #3 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
65-
bcmod(): Argument #3 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
66-
bcpowmod(): Argument #4 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
67-
bcpow(): Argument #3 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
68-
bcsqrt(): Argument #2 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
69-
bccomp(): Argument #3 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
70-
bcscale(): Argument #1 ($scale) must be greater than or equal to 0 and less than INT_MAX (2147483647)
61+
bcadd(): Argument #3 ($scale) must be between 0 and 2147483647
62+
bcsub(): Argument #3 ($scale) must be between 0 and 2147483647
63+
bcmul(): Argument #3 ($scale) must be between 0 and 2147483647
64+
bcdiv(): Argument #3 ($scale) must be between 0 and 2147483647
65+
bcmod(): Argument #3 ($scale) must be between 0 and 2147483647
66+
bcpowmod(): Argument #4 ($scale) must be between 0 and 2147483647
67+
bcpow(): Argument #3 ($scale) must be between 0 and 2147483647
68+
bcsqrt(): Argument #2 ($scale) must be between 0 and 2147483647
69+
bccomp(): Argument #3 ($scale) must be between 0 and 2147483647
70+
bcscale(): Argument #1 ($scale) must be between 0 and 2147483647

0 commit comments

Comments
 (0)