[PATCH] xfsdump: fix memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Need free tmphdr and newnode before return,
otherwise it will cause memory leak.

Signed-off-by: zhanchengbin <zhanchengbin1@xxxxxxxxxx>
---
 common/drive_simple.c | 1 +
 invutil/list.c        | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/drive_simple.c b/common/drive_simple.c
index 5c3ed4b..141fdcb 100644
--- a/common/drive_simple.c
+++ b/common/drive_simple.c
@@ -456,6 +456,7 @@ do_begin_read(drive_t *drivep)
 	/* can only read one media file
 	 */
 	if (contextp->dc_fmarkcnt > 0) {
+		free(tmphdr);
 		return DRIVE_ERROR_EOM;
 	}

diff --git a/invutil/list.c b/invutil/list.c
index 46fb291..a3a4cfd 100644
--- a/invutil/list.c
+++ b/invutil/list.c
@@ -52,8 +52,10 @@ node_create(int hidden, int expanded, int level, int deleted, int file_idx, char
 	return NULL;

     newdata = malloc(sizeof(*newdata));
-    if(newdata == NULL)
+    if(newdata == NULL) {
+	free(newnode);
 	return NULL;
+    }

     newdata->hidden = hidden;
     newdata->expanded = expanded;
--
2.33.0




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux