summaryrefslogtreecommitdiff
path: root/ext/bcmath/bcmath.c
diff options
context:
space:
mode:
authorRasmus Lerdorf <rasmus@php.net>2003-04-02 23:50:41 +0000
committerRasmus Lerdorf <rasmus@php.net>2003-04-02 23:50:41 +0000
commitbb0637213fe77f4f27c7f05df61017f858321a22 (patch)
tree1657a7f4f10892fd0117701cfb717b4173e34359 /ext/bcmath/bcmath.c
parentb3ac7b808dfd963598b0927fdfdc80090e24ab6a (diff)
downloadphp-git-bb0637213fe77f4f27c7f05df61017f858321a22.tar.gz
Negative precision makes no sense, so check for that, but let the memory
manager error out on huge non-negative precision args
Diffstat (limited to 'ext/bcmath/bcmath.c')
-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 942789c540..9da0a2f727 100644
--- a/ext/bcmath/bcmath.c
+++ b/ext/bcmath/bcmath.c
@@ -96,7 +96,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;
@@ -144,7 +144,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;
@@ -189,7 +189,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;
@@ -234,7 +234,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;
@@ -279,7 +279,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;
@@ -371,7 +371,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;
@@ -416,7 +416,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;
@@ -458,7 +458,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;
@@ -492,7 +492,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;
}
/* }}} */