From 2e4b911386a88cfb3d34e8578d0f728f684d13e5 Mon Sep 17 00:00:00 2001 From: mbkma Date: Sat, 13 Feb 2021 11:02:06 +0100 Subject: mp.c: mp_reciprocal: fix when calling it with same arguments. --- src/mp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mp.c b/src/mp.c index 1f3965e..40aacdc 100644 --- a/src/mp.c +++ b/src/mp.c @@ -403,8 +403,11 @@ mp_invert_sign(const MPNumber *x, MPNumber *z) void mp_reciprocal(const MPNumber *x, MPNumber *z) { - mpc_set_si(z->num, 1, MPC_RNDNN); - mpc_fr_div(z->num, mpc_realref(z->num), x->num, MPC_RNDNN); + mpc_t temp; + mpc_init2(temp, PRECISION); + mpc_set_ui(temp, 1, MPC_RNDNN); + mpc_fr_div(z->num, mpc_realref(temp), x->num, MPC_RNDNN); + mpc_clear(temp); } void -- cgit v1.2.1