Commit 62442d4f3303f663cadf1976d351e5860a69c1db

Dmitry Kovalenko 2016-06-02T09:40:55

Fix mp_add_d() This closes #64

diff --git a/bn_mp_add_d.c b/bn_mp_add_d.c
index 4d4e1df..21b0e1d 100644
--- a/bn_mp_add_d.c
+++ b/bn_mp_add_d.c
@@ -49,9 +49,6 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c)
   /* old number of used digits in c */
   oldused = c->used;
 
-  /* sign always positive */
-  c->sign = MP_ZPOS;
-
   /* source alias */
   tmpa    = a->dp;
 
@@ -96,6 +93,9 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c)
      ix       = 1;
   }
 
+  /* sign always positive */
+  c->sign = MP_ZPOS;
+
   /* now zero to oldused */
   while (ix++ < oldused) {
      *tmpc++ = 0;