1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

cov: avoid leak when repeating options

Do not leak previous buffer, when option is set more then once.
This commit is contained in:
Zdenek Kabelac 2021-04-22 17:53:45 +02:00
parent 7e77e250a9
commit 3d96203e21
2 changed files with 5 additions and 0 deletions

View File

@ -987,18 +987,22 @@ static int read_options(int argc, char *argv[])
break;
case 'k':
kill_vg = 1;
free(arg_vg_name);
arg_vg_name = strdup(optarg);
break;
case 'r':
drop_vg = 1;
free(arg_vg_name);
arg_vg_name = strdup(optarg);
break;
case 'E':
gl_enable = 1;
free(arg_vg_name);
arg_vg_name = strdup(optarg);
break;
case 'D':
gl_disable = 1;
free(arg_vg_name);
arg_vg_name = strdup(optarg);
break;
case 'S':

View File

@ -1774,6 +1774,7 @@ static int _get_one_setting(struct cmd_context *cmd, struct settings *set, char
}
if (!strncmp(key, "backup_file", strlen("backup_file"))) {
free(set->backup_file);
if ((set->backup_file = strdup(val)))
return 1;
return 0;