erofs-utils: mkfs: fix a memory leak of compression type configuration
PATCH v2 1/1 erofs-utils: mkfs: fix a memory leak of compression type configuration
Release the memory allocated for compression type configuration. And no need to consider !optarg case since getopt_long() will do that.
--- lib/config.c | 3 +++ mkfs/main.c | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-)
lib/config.c +3 -0
@@ -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 */
mkfs/main.c +0 -4
@@ -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] ==',' ) {
Signature · 1 line
2.17.1
Hi Yue,
Quoted 5 lines · 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 <[email protected]>---
What's the difference between v1?
The patch itself looks good to me, but I need to try later.
Thanks,
Gao Xiang
Quoted 35 lines
lib/config.c | 3 +++ mkfs/main.c | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-)lib/config.c +3
-0@@ -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 */ mkfs/main.c +0
-4@@ -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] ==',' ) {Signature · 1 line
2.17.1
Hi Xiang,
Quoted 10 lines · On Mon, 25 Jul 2022 13:56:38 +0800 Gao Xiang <[email protected]>…
Hi Yue,
Quoted 5 lines · 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 <[email protected]>---
What's the difference between v1?
just fix 'configration' -> 'configuration' in summary line.
Quoted 40 lines
The patch itself looks good to me, but I need to try later.
Thanks,
Gao XiangQuoted 35 lines
lib/config.c | 3 +++ mkfs/main.c | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-)lib/config.c +3
-0@@ -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 */ mkfs/main.c +0
-4@@ -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] ==',' ) {Signature · 1 line
2.17.1