summaryrefslogtreecommitdiff
path: root/ext/bcmath/bcmath.c
diff options
context:
space:
mode:
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);