Skip to content

Commit 6724cf9

Browse files
committed
Close file descriptor leak
1 parent d0cdca9 commit 6724cf9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libpkg/pkg_add.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,15 +1338,18 @@ pkg_add_fromdir(struct pkg *pkg, const char *src)
13381338
}
13391339
kh_find(hls, hardlinks, st.st_ino, path);
13401340
if (path != NULL) {
1341-
if (create_hardlink(pkg, f, path) == EPKG_FATAL)
1341+
if (create_hardlink(pkg, f, path) == EPKG_FATAL) {
1342+
close(fd);
13421343
return (EPKG_FATAL);
1344+
}
13431345
} else {
13441346
if (create_regfile(pkg, f, NULL, NULL, fd, NULL) == EPKG_FATAL) {
13451347
close(fd);
13461348
return (EPKG_FATAL);
13471349
}
13481350
kh_safe_add(hls, hardlinks, f->path, st.st_ino);
13491351
}
1352+
close(fd);
13501353
} else {
13511354
pkg_emit_error("Invalid file type");
13521355
return (EPKG_FATAL);

0 commit comments

Comments
 (0)