aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--URPM.xs10
1 files changed, 7 insertions, 3 deletions
diff --git a/URPM.xs b/URPM.xs
index 4b59da5..03b11a2 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -965,7 +965,9 @@ open_archive(char *filename, int *empty_archive) {
if (read(fd, &buf, sizeof(buf)) != sizeof(buf) || strncmp(buf.header, "cz[0", 4) || strncmp(buf.trailer, "0]cz", 4)) {
/* this is not an archive, open it without magic, but first rewind at begin of file */
lseek(fd, 0, SEEK_SET);
- return fdDup(fd);
+ rfd = fdDup(fd);
+ close(fd);
+ return rfd;
} else if (pos == 0) {
*empty_archive = 1;
} else {
@@ -1175,8 +1177,8 @@ update_header(char *filename, URPM__Package pkg, __attribute__((unused)) int kee
Fclose(fd);
return 1;
}
- }
- }
+ } else close(d);
+ } else close(d);
}
return 0;
}
@@ -2501,6 +2503,7 @@ Trans_add(trans, pkg, ...)
if (SvROK(ST(i+1)) && SvTYPE(SvRV(ST(i+1))) == SVt_PVAV) {
AV *excludepath = (AV*)SvRV(ST(i+1));
I32 j = 1 + av_len(excludepath);
+ if (relocations) free(relocations);
relocations = calloc(j + 1, sizeof(rpmRelocation));
while (--j >= 0) {
SV **e = av_fetch(excludepath, j, 0);
@@ -3196,6 +3199,7 @@ Urpm_stream2header(fp)
pkg->h = headerRead(fd, HEADER_MAGIC_YES);
if (pkg->h)
XPUSHs(sv_setref_pv(sv_newmortal(), "URPM::Package", (void*)pkg));
+ else free(pkg);
Fclose(fd);
}