diff options
author | Chris Wright <daverandom@php.net> | 2014-08-18 13:49:28 +0100 |
---|---|---|
committer | Chris Wright <daverandom@php.net> | 2014-08-18 13:56:02 +0100 |
commit | 1e3435b2898ea2b9e16ca92064edd8fa1a07b44c (patch) | |
tree | 6f2578ef2460211e776d1aaceb2f40b09ec99cae /ext/bcmath/bcmath.c | |
parent | 35189d2dd68f9451512c018ed26918652f48a4fd (diff) | |
download | php-git-1e3435b2898ea2b9e16ca92064edd8fa1a07b44c.tar.gz |
Return old scale value from bcscale()
Fix for #67855
Diffstat (limited to 'ext/bcmath/bcmath.c')
-rw-r--r-- | ext/bcmath/bcmath.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index 4b8c7c5f18..39228ba7ce 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -537,15 +537,19 @@ PHP_FUNCTION(bccomp) Sets default scale parameter for all bc math functions */ PHP_FUNCTION(bcscale) { - long new_scale; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &new_scale) == FAILURE) { + long old_scale, new_scale; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &new_scale) == FAILURE) { return; } - BCG(bc_precision) = ((int)new_scale < 0) ? 0 : new_scale; + old_scale = BCG(bc_precision); + + if (ZEND_NUM_ARGS() == 1) { + BCG(bc_precision) = ((int)new_scale < 0) ? 0 : new_scale; + } - RETURN_TRUE; + RETURN_LONG(old_scale); } /* }}} */ |