diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-08-06 20:46:37 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-08-06 20:46:37 +0000 |
commit | 66bf208cb75c490cbd70098eb671ed5f1b58f5fe (patch) | |
tree | cdb528721704148f265f8955f7a91d67623cf75f | |
parent | dc8fd0c368174845e5afd96979bf8ab3528906fc (diff) |
Plug some memory leaks; from Patrick Latifi
-rw-r--r-- | usr.sbin/pkg_install/add/main.c | 5 | ||||
-rw-r--r-- | usr.sbin/pkg_install/add/perform.c | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/file.c | 7 |
3 files changed, 12 insertions, 6 deletions
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index 451d2bfc78c..dd4997d1e5d 100644 --- a/usr.sbin/pkg_install/add/main.c +++ b/usr.sbin/pkg_install/add/main.c @@ -1,7 +1,7 @@ -/* $OpenBSD: main.c,v 1.17 2003/07/04 17:31:19 avsm Exp $ */ +/* $OpenBSD: main.c,v 1.18 2003/08/06 20:46:36 millert Exp $ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: main.c,v 1.17 2003/07/04 17:31:19 avsm Exp $"; +static const char rcsid[] = "$OpenBSD: main.c,v 1.18 2003/08/06 20:46:36 millert Exp $"; #endif /* @@ -164,6 +164,7 @@ main(int argc, char **argv) fprintf(stderr, "failing path was %s\n", pkgs[ch]); exit(1); } + free(s); } else { /* look for the file(pattern) in the expected places */ if (!(cp = fileFindByPath(NULL, *argv))) { diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index 0cc3a52dd98..3333a33d222 100644 --- a/usr.sbin/pkg_install/add/perform.c +++ b/usr.sbin/pkg_install/add/perform.c @@ -1,7 +1,7 @@ -/* $OpenBSD: perform.c,v 1.29 2003/08/01 08:56:01 espie Exp $ */ +/* $OpenBSD: perform.c,v 1.30 2003/08/06 20:46:36 millert Exp $ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: perform.c,v 1.29 2003/08/01 08:56:01 espie Exp $"; +static const char rcsid[] = "$OpenBSD: perform.c,v 1.30 2003/08/06 20:46:36 millert Exp $"; #endif /* @@ -367,6 +367,7 @@ pkg_do(char *pkg) printf("\t`%s' loaded successfully\n", p->name); /* Nuke the temporary playpen */ leave_playpen(cp); + free(cp); restore_dirs(saved_Current, saved_Previous); } @@ -511,6 +512,7 @@ pkg_do(char *pkg) char *t; t=strrchr(contents, '/'); strlcpy(t+1, s, contents + sizeof(contents) - (t+1)); + free(s); }else{ errx(1,"Where did our dependency go?!"); /* this shouldn't happen... X-) */ diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c index e67f90ae8a1..aff2263fa8c 100644 --- a/usr.sbin/pkg_install/lib/file.c +++ b/usr.sbin/pkg_install/lib/file.c @@ -1,7 +1,7 @@ -/* $OpenBSD: file.c,v 1.24 2003/08/06 20:45:47 millert Exp $ */ +/* $OpenBSD: file.c,v 1.25 2003/08/06 20:46:36 millert Exp $ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: file.c,v 1.24 2003/08/06 20:45:47 millert Exp $"; +static const char rcsid[] = "$OpenBSD: file.c,v 1.25 2003/08/06 20:46:36 millert Exp $"; #endif /* @@ -365,6 +365,7 @@ fileFindByPath(char *base, char *fname) if (ispkgpattern(fname)) { if ((cp=findbestmatchingname(".",fname)) != NULL) { strlcpy(tmp, cp, sizeof(tmp)); + free(cp); return tmp; } } else { @@ -390,6 +391,7 @@ fileFindByPath(char *base, char *fname) assert(s != NULL); strlcpy(s+1, cp, tmp + sizeof(tmp) - (s+1)); + free(cp); return tmp; } } else { @@ -418,6 +420,7 @@ fileFindByPath(char *base, char *fname) char *t; t=strrchr(tmp, '/'); strlcpy(t+1, s, tmp + sizeof(tmp) - (t+1)); + free(s); return tmp; } } else { |