@@ -74,13 +74,23 @@ raise_mod_status bc_raisemod(bc_num base, bc_num expo, bc_num mod, bc_num *resul
74
74
75
75
/* Do the calculation. */
76
76
while (!bc_is_zero (exponent )) {
77
- (void ) bc_divmod (exponent , BCG (_two_ ), & exponent , & parity , 0 );
77
+ bc_num temp_quot = bc_copy_num (exponent );
78
+ (void ) bc_divmod (exponent , BCG (_two_ ), & temp_quot , & parity , 0 );
79
+ bc_free_num (& exponent );
80
+ exponent = temp_quot ;
81
+
78
82
if (!bc_is_zero (parity )) {
79
83
bc_multiply_ex (temp , power , & temp , scale );
80
- (void ) bc_modulo (temp , modulus , & temp , scale );
84
+ bc_num temp_rem = bc_copy_num (temp );
85
+ (void ) bc_modulo (temp , modulus , & temp_rem , scale );
86
+ bc_free_num (& temp );
87
+ temp = temp_rem ;
81
88
}
82
89
bc_multiply_ex (power , power , & power , scale );
83
- (void ) bc_modulo (power , modulus , & power , scale );
90
+ bc_num temp_rem = bc_copy_num (power );
91
+ (void ) bc_modulo (power , modulus , & temp_rem , scale );
92
+ bc_free_num (& power );
93
+ power = temp_rem ;
84
94
}
85
95
86
96
/* Assign the value. */
0 commit comments