]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #27258 (moved FPE check to correct location).
authorIlia Alshanetsky <iliaa@php.net>
Sun, 15 Feb 2004 17:23:11 +0000 (17:23 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 15 Feb 2004 17:23:11 +0000 (17:23 +0000)
     Fixed several possible FPE.

ext/gmp/gmp.c

index b8b67709184bfd894c2ff485e362345afb237a7c..6b08129cddd07b71282aa591d84b3148439d1d51 100644 (file)
@@ -309,6 +309,11 @@ static inline void gmp_zval_binary_ui_op_ex(zval *return_value, zval **a_arg, zv
                FETCH_GMP_ZVAL(gmpnum_b, b_arg);
        }
 
+       convert_to_long_ex(b_arg);
+       if (!Z_LVAL_PP(b_arg)) {
+               RETURN_FALSE;
+       }
+
        INIT_GMP_NUM(gmpnum_result);
        if(use_ui && gmp_ui_op) {
                if(allow_ui_return) {
@@ -348,6 +353,11 @@ static inline void gmp_zval_binary_ui_op2_ex(zval *return_value, zval **a_arg, z
                FETCH_GMP_ZVAL(gmpnum_b, b_arg);
        }
 
+       convert_to_long_ex(b_arg);
+       if (!Z_LVAL_PP(b_arg)) {
+               RETURN_FALSE;
+       }
+
        INIT_GMP_NUM(gmpnum_result1);
        INIT_GMP_NUM(gmpnum_result2);
 
@@ -814,11 +824,6 @@ ZEND_FUNCTION(gmp_powm)
                WRONG_PARAM_COUNT;
        }
 
-       convert_to_long_ex(mod_arg);
-       if (!Z_LVAL_PP(mod_arg)) {
-               RETURN_FALSE;
-       }
-
        FETCH_GMP_ZVAL(gmpnum_base, base_arg);
        if(Z_TYPE_PP(exp_arg) == IS_LONG && Z_LVAL_PP(exp_arg) >= 0) {
                use_ui=1;
@@ -827,6 +832,11 @@ ZEND_FUNCTION(gmp_powm)
        }
        FETCH_GMP_ZVAL(gmpnum_mod, mod_arg);
 
+       convert_to_long_ex(mod_arg);
+       if (!Z_LVAL_PP(mod_arg)) {
+               RETURN_FALSE;
+       }
+
        INIT_GMP_NUM(gmpnum_result);
        if(use_ui) {
                mpz_powm_ui(*gmpnum_result, *gmpnum_base, (unsigned long)Z_LVAL_PP(exp_arg), *gmpnum_mod);