diff options
author | Thierry Vignaud <thierry.vignaud@gmail.com> | 2013-08-30 04:06:24 +0200 |
---|---|---|
committer | Thierry Vignaud <thierry.vignaud@gmail.com> | 2013-10-03 23:17:06 +0200 |
commit | fa8c377d6befb9131daf854ee600e1ebc9507290 (patch) | |
tree | d946cb9cf4f64ba3e95743e1b8706ec4808fc445 | |
parent | 55b74bdca7060f49f61bed85d7b53dd85957d14b (diff) | |
download | perl-URPM-fa8c377d6befb9131daf854ee600e1ebc9507290.tar perl-URPM-fa8c377d6befb9131daf854ee600e1ebc9507290.tar.gz perl-URPM-fa8c377d6befb9131daf854ee600e1ebc9507290.tar.bz2 perl-URPM-fa8c377d6befb9131daf854ee600e1ebc9507290.tar.xz perl-URPM-fa8c377d6befb9131daf854ee600e1ebc9507290.zip |
coverity: fix "Resource leak"
'leaked_storage: Variable "foo" going out of scope leaks the storage it
points to.'
-rw-r--r-- | URPM.xs | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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); } |