diff options
-rw-r--r-- | ext/bcmath/bcmath.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index 60e2a5ce4b..b5b16716b7 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -97,7 +97,7 @@ PHP_RINIT_FUNCTION(bcmath) if (cfg_get_long("bcmath.scale", &bc_precision) == FAILURE) { bc_precision = 0; } - + if(bc_precision<0) bc_precision=0; bc_init_numbers(TSRMLS_C); return SUCCESS; @@ -145,7 +145,7 @@ PHP_FUNCTION(bcadd) WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -191,7 +191,7 @@ PHP_FUNCTION(bcsub) WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -237,7 +237,7 @@ PHP_FUNCTION(bcmul) WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -283,7 +283,7 @@ PHP_FUNCTION(bcdiv) WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -411,7 +411,7 @@ PHP_FUNCTION(bcpow) WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -457,7 +457,7 @@ PHP_FUNCTION(bcsqrt) WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -500,7 +500,7 @@ PHP_FUNCTION(bccomp) WRONG_PARAM_COUNT; } convert_to_long_ex(scale_param); - scale = (int) Z_LVAL_PP(scale_param); + scale = (int) (Z_LVAL_PP(scale_param)<0) ? 0:Z_LVAL_PP(scale_param); break; default: WRONG_PARAM_COUNT; @@ -534,7 +534,8 @@ PHP_FUNCTION(bcscale) } convert_to_long_ex(new_scale); - bc_precision = Z_LVAL_PP(new_scale); + bc_precision = (Z_LVAL_PP(new_scale)<0) ? 0 : Z_LVAL_PP(new_scale); + RETURN_TRUE; } /* }}} */ |