summaryrefslogtreecommitdiff
path: root/ext/bcmath
diff options
context:
space:
mode:
authorRasmus Lerdorf <rasmus@php.net>2003-04-02 23:51:52 +0000
committerRasmus Lerdorf <rasmus@php.net>2003-04-02 23:51:52 +0000
commit1dba0c1ba7eed8374621525e0dc8c2550f201391 (patch)
tree5ea2ff8880441c0996645a8cd4c5af2fa065530c /ext/bcmath
parent066a68d7fa1fc24f83c26c9c5ce92def34674154 (diff)
downloadphp-git-1dba0c1ba7eed8374621525e0dc8c2550f201391.tar.gz
MFB: Check for negative precision
Diffstat (limited to 'ext/bcmath')
-rw-r--r--ext/bcmath/bcmath.c19
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;
}
/* }}} */