_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 <allan@archlinux.org>
This commit is contained in:
Allan McRae 2022-12-13 00:30:43 +10:00
parent ea83fd3927
commit 19a8587459

View file

@ -653,7 +653,6 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
} }
_alpm_archive_read_free(archive); _alpm_archive_read_free(archive);
close(fd);
/* internal fields for package struct */ /* internal fields for package struct */
newpkg->origin = ALPM_PKG_FROM_FILE; 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; newpkg->infolevel |= INFRQ_FILES;
} }
close(fd);
return newpkg; return newpkg;
pkg_invalid: pkg_invalid: