Commit 64177349fcb7a1b94eea5b608291b8c00bf6cafc

Francois Perrad 2015-10-25T16:25:20

avoid side effects on right hand of logical operator

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/bn_mp_expt_d_ex.c b/bn_mp_expt_d_ex.c
index bc15878..8b12d24 100644
--- a/bn_mp_expt_d_ex.c
+++ b/bn_mp_expt_d_ex.c
@@ -41,9 +41,11 @@ int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
       }
 
       /* square */
-      if (b > 1 && (res = mp_sqr (&g, &g)) != MP_OKAY) {
-        mp_clear (&g);
-        return res;
+      if (b > 1) {
+        if ((res = mp_sqr (&g, &g)) != MP_OKAY) {
+          mp_clear (&g);
+          return res;
+        }
       }
 
       /* shift to next bit */