Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] erofs-utils: mkfs: fix a memory leak of compression type configuration
@ 2022-07-25  5:45 Yue Hu
  2022-07-25  5:56 ` Gao Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Yue Hu @ 2022-07-25  5:45 UTC (permalink / raw)
  To: linux-erofs; +Cc: Yue Hu

Release the memory allocated for compression type configuration. And no
need to consider !optarg case since getopt_long() will do that.

Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
 lib/config.c | 3 +++
 mkfs/main.c  | 4 ----
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/config.c b/lib/config.c
index 3963df2..c316a54 100644
--- a/lib/config.c
+++ b/lib/config.c
@@ -55,6 +55,9 @@ void erofs_exit_configure(void)
 #endif
 	if (cfg.c_img_path)
 		free(cfg.c_img_path);
+
+	if (cfg.c_compr_alg_master)
+		free(cfg.c_compr_alg_master);
 }
 
 static unsigned int fullpath_prefix;	/* root directory prefix length */
diff --git a/mkfs/main.c b/mkfs/main.c
index deb8e1f..9f5f1dc 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -212,10 +212,6 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 				  long_options, NULL)) != -1) {
 		switch (opt) {
 		case 'z':
-			if (!optarg) {
-				cfg.c_compr_alg_master = "(default)";
-				break;
-			}
 			/* get specified compression level */
 			for (i = 0; optarg[i] != '\0'; ++i) {
 				if (optarg[i] == ',') {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-25  6:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-25  5:45 [PATCH v2] erofs-utils: mkfs: fix a memory leak of compression type configuration Yue Hu
2022-07-25  5:56 ` Gao Xiang
2022-07-25  6:03   ` Yue Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox