summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1998-07-03 18:51:15 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1998-07-03 18:51:15 +0000
commit1684897fe0a5bd04134380d8c1dc2f9cf8d9aee4 (patch)
tree16dc655198e6a7c0c4a406c40310e0d4b6b0cf96 /usr.bin
parent3278fc49e80f8e59b760d080bf10361809fb6272 (diff)
Better fix from Christos:
deleting a suffix that has 0 source references causes core-dump. Fix: when an unused suffix gets removed, delete it from the suffix list. There is still, however a duplicate free(), which I work around by passing the Suffix back as a return value to SuffRemove() (it gets set to NULL when the suffix is freed). This is probably not the best way to fix this.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/suff.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c
index 128ef09bf71..c39efb5bceb 100644
--- a/usr.bin/make/suff.c
+++ b/usr.bin/make/suff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: suff.c,v 1.9 1998/07/02 21:32:10 millert Exp $ */
+/* $OpenBSD: suff.c,v 1.10 1998/07/03 18:51:14 millert Exp $ */
/* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */
/*
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
-static char rcsid[] = "$OpenBSD: suff.c,v 1.9 1998/07/02 21:32:10 millert Exp $";
+static char rcsid[] = "$OpenBSD: suff.c,v 1.10 1998/07/03 18:51:14 millert Exp $";
#endif
#endif /* not lint */
@@ -168,7 +168,7 @@ static int SuffGNHasNameP __P((ClientData, ClientData));
static void SuffUnRef __P((ClientData, ClientData));
static void SuffFree __P((ClientData));
static void SuffInsert __P((Lst, Suff *));
-static void SuffRemove __P((Lst, Suff *));
+static Suff *SuffRemove __P((Lst, Suff *));
static Boolean SuffParseTransform __P((char *, Suff **, Suff **));
static int SuffRebuildGraph __P((ClientData, ClientData));
static int SuffAddSrc __P((ClientData, ClientData));
@@ -370,6 +370,13 @@ SuffFree (sp)
if (s == emptySuff)
emptySuff = NULL;
+#ifdef notdef
+ /* We don't delete suffixes in order, so we cannot use this */
+ if (s->refCount)
+ Punt("Internal error deleting suffix `%s' with refcount = %d", s->name,
+ s->refCount);
+#endif
+
Lst_Destroy (s->ref, NOFREE);
Lst_Destroy (s->children, NOFREE);
Lst_Destroy (s->parents, NOFREE);
@@ -392,14 +399,18 @@ SuffFree (sp)
* suffix is possibly freed
*-----------------------------------------------------------------------
*/
-static void
+static Suff *
SuffRemove(l, s)
Lst l;
Suff *s;
{
SuffUnRef((ClientData) l, (ClientData) s);
- if (s->refCount == 0)
+ if (s->refCount == 0) {
+ SuffUnRef ((ClientData) sufflist, (ClientData) s);
SuffFree((ClientData) s);
+ s = NULL;
+ }
+ return (s);
}
/*-
@@ -691,13 +702,12 @@ Suff_EndTransform(gnp, dummy)
* We'll be called twice when the next target is seen, but .c and .o
* are only linked once...
*/
- if (t != suffNull)
- SuffRemove(t->children, s);
+ s = SuffRemove(t->children, s);
/*
* Remove the target from the source's parents list
*/
- if (s != suffNull)
+ if (s != NULL)
SuffRemove(s->parents, t);
} else if ((gn->type & OP_TRANSFORM) && DEBUG(SUFF)) {
printf("transformation %s complete\n", gn->name);