aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miscutils/make.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/miscutils/make.c b/miscutils/make.c
index 8c74d7113..871c434f8 100644
--- a/miscutils/make.c
+++ b/miscutils/make.c
@@ -462,15 +462,24 @@ newcmd(struct cmd **cphead, char *str)
462 /*(*cphead)->c_next = NULL; - xzalloc did it */ 462 /*(*cphead)->c_next = NULL; - xzalloc did it */
463 (*cphead)->c_cmd = xstrdup(str); 463 (*cphead)->c_cmd = xstrdup(str);
464 /*(*cphead)->c_refcnt = 0; */ 464 /*(*cphead)->c_refcnt = 0; */
465 (*cphead)->c_makefile = makefile; 465 if (makefile)
466 (*cphead)->c_makefile = xstrdup(makefile);
466 (*cphead)->c_dispno = dispno; 467 (*cphead)->c_dispno = dispno;
467} 468}
468 469
469static void 470static void
470freecmds(struct cmd *cp) 471freecmds(struct cmd *cp)
471{ 472{
472 if (cp && --cp->c_refcnt <= 0) 473 struct cmd *nextcp;
473 llist_free((llist_t *)cp, free); 474
475 if (cp && --cp->c_refcnt <= 0) {
476 for (; cp; cp = nextcp) {
477 nextcp = cp->c_next;
478 free(cp->c_cmd);
479 free((void *)cp->c_makefile);
480 free(cp);
481 }
482 }
474} 483}
475 484
476static struct name * 485static struct name *