Added missing error check inside bcpowmod().

This commit is contained in:
Ilia Alshanetsky 2007-06-08 00:41:57 +00:00
parent a6340d27ae
commit 1bd2791cd4
2 changed files with 11 additions and 6 deletions

1
NEWS
View File

@ -8,6 +8,7 @@ PHP NEWS
- Added missing open_basedir checks to CGI. (anight at eyelinkmedia dot com,
Tony)
- Added missing format validator to unpack() function. (Ilia)
- Added missing error check inside bcpowmod(). (Ilia)
- Fixed several integer overflows in ImageCreate(), ImageCreateTrueColor(),
ImageCopyResampled() and ImageFilledPolygon() reported by Mattias Bengtsson.
(Tony)

View File

@ -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);