From 04424f5e89e85d77be0c613af1121fadfbd22065 Mon Sep 17 00:00:00 2001 From: Aurelien Foret Date: Wed, 9 Nov 2005 21:50:47 +0000 Subject: fixed a file descriptor leak --- lib/libalpm/add.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/libalpm/add.c') diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index a60b0633..689172c5 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -447,17 +447,20 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) if(nb) { char *temp; char *md5_local, *md5_pkg; + int fd; - md5_local = MDFile(expath); /* extract the package's version to a temporary file and md5 it */ temp = strdup("/tmp/alpm_XXXXXX"); - mkstemp(temp); + fd = mkstemp(temp); if(tar_extract_file(tar, temp)) { alpm_logaction("could not extract %s (%s)", pathname, strerror(errno)); errors++; - FREE(md5_local); + unlink(temp); + FREE(temp); + close(fd); continue; } + md5_local = MDFile(expath); md5_pkg = MDFile(temp); /* append the new md5 hash to it's respective entry in info->backup * (it will be the new orginal) @@ -550,6 +553,7 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) FREE(md5_orig); unlink(temp); FREE(temp); + close(fd); } else { if(!notouch) { _alpm_log(PM_LOG_FLOW2, "extracting %s", pathname); -- cgit v1.2.3-70-g09d2