summaryrefslogtreecommitdiff
path: root/ext/bcmath/bcmath.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-06-08 00:41:57 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-06-08 00:41:57 +0000
commit1bd2791cd4e814e394066141590e38d948b69bb3 (patch)
tree969f2670ef2e4784d87eed0c35cc65610979ae93 /ext/bcmath/bcmath.c
parenta6340d27aeff1864b65c608c605838dc73f9741e (diff)
downloadphp-git-1bd2791cd4e814e394066141590e38d948b69bb3.tar.gz
Added missing error check inside bcpowmod().
Diffstat (limited to 'ext/bcmath/bcmath.c')
-rw-r--r--ext/bcmath/bcmath.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c
index 3925c5e311..7c6ebe5255 100644
--- a/ext/bcmath/bcmath.c
+++ b/ext/bcmath/bcmath.c
@@ -465,13 +465,17 @@ PHP_FUNCTION(bcpowmod)
scale_int = (int) ((int)scale < 0) ? 0 : scale;
- bc_raisemod(first, second, mod, &result, scale_int TSRMLS_CC);
- if (result->n_scale > scale) {
- result->n_scale = scale;
+ if (bc_raisemod(first, second, mod, &result, scale_int TSRMLS_CC) != -1) {
+ if (result->n_scale > scale) {
+ result->n_scale = scale;
+ }
+ Z_STRVAL_P(return_value) = bc_num2str(result);
+ Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
+ Z_TYPE_P(return_value) = IS_STRING;
+ } else {
+ RETVAL_FALSE;
}
- Z_STRVAL_P(return_value) = bc_num2str(result);
- Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
- Z_TYPE_P(return_value) = IS_STRING;
+
bc_free_num(&first);
bc_free_num(&second);
bc_free_num(&mod);