fix memory leak in mp_init_copy() This closes #59
diff --git a/bn_mp_init_copy.c b/bn_mp_init_copy.c
index 9e15f36..76c5e42 100644
--- a/bn_mp_init_copy.c
+++ b/bn_mp_init_copy.c
@@ -23,7 +23,12 @@ int mp_init_copy (mp_int * a, mp_int * b)
if ((res = mp_init_size (a, b->used)) != MP_OKAY) {
return res;
}
- return mp_copy (b, a);
+
+ if((res = mp_copy (b, a)) != MP_OKAY) {
+ mp_clear(a);
+ }
+
+ return res;
}
#endif