Now @mp_drop@ checks its argument is non-NULL before attempting to free
authormdw <mdw>
Sat, 3 Feb 2001 16:05:41 +0000 (16:05 +0000)
committermdw <mdw>
Sat, 3 Feb 2001 16:05:41 +0000 (16:05 +0000)
it.  Note that the macro version @MP_DROP@ doesn't do this.

pgen.c
share.c

diff --git a/pgen.c b/pgen.c
index eebd966..74a10bc 100644 (file)
--- a/pgen.c
+++ b/pgen.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: pgen.c,v 1.6 2000/10/08 12:11:22 mdw Exp $
+ * $Id: pgen.c,v 1.7 2001/02/03 16:05:32 mdw Exp $
  *
  * Prime generation glue
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: pgen.c,v $
+ * Revision 1.7  2001/02/03 16:05:32  mdw
+ * Now @mp_drop@ checks its argument is non-NULL before attempting to free
+ * it.  Note that the macro version @MP_DROP@ doesn't do this.
+ *
  * Revision 1.6  2000/10/08 12:11:22  mdw
  * Use @MP_EQ@ instead of @MP_CMP@.
  *
@@ -317,8 +321,7 @@ mp *pgen(const char *name, mp *d, mp *m, pgen_proc *event, void *ectx,
     ev.m = 0;
   }
   ev.r->ops->destroy(ev.r);
-  if (d != MP_NEW)
-    mp_drop(d);
+  mp_drop(d);
 
   return (ev.m);
 }
@@ -353,8 +356,7 @@ static int verify(dstr *v)
 
   mp_drop(m);
   mp_drop(q);
-  if (p)
-    mp_drop(p);
+  mp_drop(p);
   assert(mparena_count(MPARENA_GLOBAL) == 0);
   return (ok);
 }
diff --git a/share.c b/share.c
index cc793db..d0fd0f5 100644 (file)
--- a/share.c
+++ b/share.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: share.c,v 1.5 2000/12/06 20:30:10 mdw Exp $
+ * $Id: share.c,v 1.6 2001/02/03 16:05:41 mdw Exp $
  *
  * Shamir's secret sharing
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: share.c,v $
+ * Revision 1.6  2001/02/03 16:05:41  mdw
+ * Now @mp_drop@ checks its argument is non-NULL before attempting to free
+ * it.  Note that the macro version @MP_DROP@ doesn't do this.
+ *
  * Revision 1.5  2000/12/06 20:30:10  mdw
  * Change secret sharing interface: present the secret at share
  * construction time.
@@ -102,17 +106,14 @@ void share_destroy(share *s)
   /* --- Dispose of the share vector --- */
 
   if (s->v) {
-    for (i = 0; i < s->t; i++) {
-      if (s->v[i].y)
-       mp_drop(s->v[i].y);
-    }
+    for (i = 0; i < s->t; i++)
+      mp_drop(s->v[i].y);
     xfree(s->v);
   }
 
   /* --- Other stuff --- */
 
-  if (s->p)
-    mp_drop(s->p);
+  mp_drop(s->p);
 }
 
 /* --- @share_mkshares@ --- *
@@ -182,8 +183,7 @@ mp *share_get(share *s, mp *d, unsigned x)
   /* --- Various bits of initialization --- */
 
   mp_build(&u, &uw, &uw + 1);
-  if (d)
-    mp_drop(d);
+  mp_drop(d);
 
   /* --- Evaluate the polynomial at %$x = i + 1$% --- */
 
@@ -293,8 +293,7 @@ mp *share_combine(share *s)
   }
 
   a = mpbarrett_reduce(&mb, a, a);
-  if (m)
-    mp_drop(m);
+  mp_drop(m);
   mpbarrett_destroy(&mb);
   return (a);
 }