[PATCH 2/4] libmount: Free splitted optstr's when error occurred

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

 



When strdup() failed, u, v and f optstr's should be freed.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxx>
---
 libmount/src/fs.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libmount/src/fs.c b/libmount/src/fs.c
index c95cdc7..e3a2e1a 100644
--- a/libmount/src/fs.c
+++ b/libmount/src/fs.c
@@ -774,8 +774,12 @@ int mnt_fs_set_options(struct libmnt_fs *fs, const char *optstr)
 		if (rc)
 			return rc;
 		n = strdup(optstr);
-		if (!n)
+		if (!n) {
+			free(u);
+			free(v);
+			free(f);
 			return -ENOMEM;
+		}
 	}
 
 	free(fs->fs_optstr);
-- 
1.7.9.2

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux