[libbdplus-devel] Fix fd leaks
anonymous
git at videolan.org
Fri Mar 3 14:33:01 CET 2017
libbdplus | branch: master | anonymous <anonymous at anonymous.org> | Fri Mar 3 15:29:50 2017 +0200| [3c39e3a968de558cca4baa2e7a45ae7a2071abe6] | committer: anonymous
Fix fd leaks
> http://git.videolan.org/gitweb.cgi/libbdplus.git/?a=commit;h=3c39e3a968de558cca4baa2e7a45ae7a2071abe6
---
src/libbdplus/bdsvm/diff.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/libbdplus/bdsvm/diff.c b/src/libbdplus/bdsvm/diff.c
index 445000c..54e5f63 100644
--- a/src/libbdplus/bdsvm/diff.c
+++ b/src/libbdplus/bdsvm/diff.c
@@ -90,10 +90,14 @@ int32_t diff_loadcore(uint8_t *addr, uint32_t vmsize, char *fname,
BD_DEBUG(DBG_BDPLUS,"[diff] Memory size is %08X, num diff-files %08X\n", size, count);
- if (trap >= count) return -1;
-
- if (size > vmsize) return -2; // Safety
-
+ if (trap >= count) {
+ fclose(fd);
+ return -1;
+ }
+ if (size > vmsize) {
+ fclose(fd);
+ return -2; // Safety
+ }
// Clear the area first.
memset(addr, 0, vmsize);
@@ -170,7 +174,10 @@ uint32_t diff_hashdb_load(uint8_t *hashname, uint8_t *fname, uint64_t offset,
shalen = sizeof(offset) + sizeof(*len) + strlen((char *)fname) + 1;
namehash = (uint8_t *)malloc( shalen );
- if (!namehash) return STATUS_INTERNAL_ERROR;
+ if (!namehash) {
+ fclose(fd);
+ return STATUS_INTERNAL_ERROR;
+ }
// SHA[64bit-offset, 32bit-len, filename]
STORE8(&namehash[0], offset);
More information about the libbdplus-devel
mailing list