ec.c: Free partially constructed points coordinatewise.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 24 Nov 2019 22:16:53 +0000 (22:16 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 27 Nov 2019 15:10:44 +0000 (15:10 +0000)
The `EC_DESTROY' macro assumes that the other coordinates are null if
and only if `p->x' is.  This works badly with the current code
structure, which fills in coordinates as it goes along, and I think this
is a better fix than trying to maintain the coordinates in temporaries
until we're done.

ec.c

diff --git a/ec.c b/ec.c
index 6280010..f0747a8 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -508,7 +508,7 @@ static PyObject *ecptnc_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
     goto end;
   return (ecpt_pywrapout(ty, &p));
 end:
-  EC_DESTROY(&p);
+  mp_drop(p.x); mp_drop(p.y); mp_drop(p.z);
   return (0);
 }
 
@@ -550,7 +550,7 @@ static PyObject *ecpt_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
     goto end;
   return (ecpt_pywrap((PyObject *)ty, &p));
 end:
-  EC_DESTROY(&p);
+  mp_drop(p.x); mp_drop(p.y); mp_drop(p.z);
   return (0);
 }