rasmus Wed Apr 2 18:51:52 2003 EDT
Modified files:
/php4/ext/bcmath bcmath.c
Log:
MFB: Check for negative precision
Index: php4/ext/bcmath/bcmath.c
diff -u php4/ext/bcmath/bcmath.c:1.52 php4/ext/bcmath/bcmath.c:1.53
--- php4/ext/bcmath/bcmath.c:1.52 Wed Mar 19 19:22:57 2003
+++ php4/ext/bcmath/bcmath.c Wed Apr 2 18:51:52 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: bcmath.c,v 1.52 2003/03/20 00:22:57 sniper Exp $ */
+/* $Id: bcmath.c,v 1.53 2003/04/02 23:51:52 rasmus Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -97,7 +97,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
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;
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php