Skip to content

Commit 63c0e74

Browse files
committed
Warning to error promotion for bcpow()
1 parent f31dae0 commit 63c0e74

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ext/bcmath/libbcmath/src/raise.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ bc_raise (bc_num num1, bc_num num2, bc_num *result, int scale)
5252
int calcscale;
5353
char neg;
5454

55-
/* Check the exponent for scale digits and convert to a long. */
56-
if (num2->n_scale != 0)
57-
php_error_docref (NULL, E_WARNING, "Non-zero scale in exponent");
58-
exponent = bc_num2long (num2);
59-
if (exponent == 0 && (num2->n_len > 1 || num2->n_value[0] != 0))
60-
php_error_docref (NULL, E_WARNING, "Exponent too large");
55+
/* Check the exponent for scale digits and convert to a long. */
56+
if (num2->n_scale != 0) {
57+
/* 2nd argument from PHP_FUNCTION(bcpow) */
58+
zend_argument_value_error(2, "must be an integer");
59+
}
60+
exponent = bc_num2long (num2);
61+
if (exponent == 0 && (num2->n_len > 1 || num2->n_value[0] != 0)) {
62+
/* 2nd argument from PHP_FUNCTION(bcpow) */
63+
zend_argument_value_error(2, "is too large");
64+
}
6165

6266
/* Special case if exponent is a zero. */
6367
if (exponent == 0)

0 commit comments

Comments
 (0)