package

simple and robust package manager
Log | Files | Refs | README

commit df29b1376eddb3ee63f68680a43d8d073ea8c1d4
parent ec33c2e787adbe8b080123c3fb4c30d1169df320
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat, 12 Jan 2019 11:36:13 +0100

fix double free error on DIR struct

Diffstat:
Mpack-build.c | 13+++----------
1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/pack-build.c b/pack-build.c @@ -184,7 +184,6 @@ pack_patch(pack const *p, char *def) int fd = -1; int ret = 0; - write(1, "E\n", 2); stralloc_init(&path); if (!stralloc_cats(&path, def)) goto err; if (!stralloc_cats(&path, "/")) goto err; @@ -192,8 +191,6 @@ pack_patch(pack const *p, char *def) if (!stralloc_cats(&path, "/")) goto err; n = path.n; - dprintf(1, "%p\n", path.x); - d[0] = "default"; d[1] = p->ver; for (i = 0; i < 2; ++i) { @@ -207,7 +204,6 @@ pack_patch(pack const *p, char *def) if (errno == ENOTDIR || errno == ENOENT) continue; goto err; } - while ((de = readdir(dp)) != NULL) { if (str_equal(de->d_name, ".")) continue; if (str_equal(de->d_name, "..")) continue; @@ -215,7 +211,6 @@ pack_patch(pack const *p, char *def) path.n = m; if (!stralloc_cats(&path, de->d_name)) goto err; if (!stralloc_0(&path)) goto err; - write(1, path.x, path.n); fd = open_read(path.x); if (fd == -1) goto err; if (dup2(fd, 0) == -1) goto err; if (forkexec_wait(argv) != 0) goto err; @@ -224,14 +219,12 @@ pack_patch(pack const *p, char *def) closedir(dp); } - dprintf(1, "%p\n", path.x); ret = 1; -err: write(1, "E\n", 2); - stralloc_free(&path); +err: stralloc_free(&path); close(fd); - closedir(dp); - return 0; + if (ret == 0) closedir(dp); + return ret; } int