From 19a8587459a8e9dbc1651f7fae79ce93c52d5067 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Tue, 13 Dec 2022 00:30:43 +1000 Subject: [PATCH] _alpm_pkg_load_internal: prevent double closing file descriptor Move closing of the file descriptor until the end of the function, as any following error will lead to a "goto error" that attempts to close it again. Signed-off-by: Allan McRae --- lib/libalpm/be_package.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index bedec723..f4d44f14 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -653,7 +653,6 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, } _alpm_archive_read_free(archive); - close(fd); /* internal fields for package struct */ newpkg->origin = ALPM_PKG_FROM_FILE; @@ -676,6 +675,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, newpkg->infolevel |= INFRQ_FILES; } + close(fd); return newpkg; pkg_invalid: