fix fd leaking and deallocation freed resource
Change-Id: Ibee4d7000bce5bc8c2e45339d4d53a242569ae4e
diff --git a/ext4_utils/ext4_utils.c b/ext4_utils/ext4_utils.c
index 60a4da3..bc5cfd0 100644
--- a/ext4_utils/ext4_utils.c
+++ b/ext4_utils/ext4_utils.c
@@ -360,6 +360,7 @@
#elif defined(__APPLE__) && defined(__MACH__)
ret = ioctl(fd, DKIOCGETBLOCKCOUNT, &size);
#else
+ close(fd);
return 0;
#endif
diff --git a/ext4_utils/output_file.c b/ext4_utils/output_file.c
index 3785b06..b34109a 100644
--- a/ext4_utils/output_file.c
+++ b/ext4_utils/output_file.c
@@ -279,6 +279,7 @@
zero_buf = malloc(info.block_size);
if (!zero_buf) {
error_errno("malloc zero_buf");
+ free(out);
return NULL;
}
memset(zero_buf, '\0', info.block_size);
@@ -419,10 +420,6 @@
goto err;
}
- munmap(data, len);
-
- close(file_fd);
-
err:
munmap(data, len);
close(file_fd);