From 683e25de59b6b7307a9654b17a4c784e8897d33a Mon Sep 17 00:00:00 2001
From: Jan Willamowius <jan@willamowius.de>
Date: 周日, 21 4月 2019 23:58:07 +0800
Subject: [PATCH] fix memory leaks on error

---
 src/library/os/os-linux.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/library/os/os-linux.c b/src/library/os/os-linux.c
index 717373a..af21f2c 100644
--- a/src/library/os/os-linux.c
+++ b/src/library/os/os-linux.c
@@ -65,11 +65,11 @@
 	struct mntent *ent;
 
 	int maxDrives, currentDrive, i, drive_found;
-	__ino64_t *statDrives;
-	DiskInfo *tmpDrives;
-	FILE *aFile;
-	DIR *disk_by_uuid_dir, *disk_by_label;
-	struct dirent *dir;
+	__ino64_t *statDrives = NULL;
+	DiskInfo *tmpDrives = NULL;
+	FILE *aFile = NULL;
+	DIR *disk_by_uuid_dir = NULL, *disk_by_label = NULL;
+	struct dirent *dir = NULL;
 	FUNCTION_RETURN result;
 
 	if (diskInfos != NULL) {
@@ -87,6 +87,8 @@
 	aFile = setmntent("/proc/mounts", "r");
 	if (aFile == NULL) {
 		/*proc not mounted*/
+		free(tmpDrives);
+		free(statDrives);
 		return FUNC_RET_ERROR;
 	}
 

--
Gitblit v1.9.1