pacman-conf: free rootdir before replacing

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Andrew Gregory 2021-01-15 23:20:56 -08:00 committed by Allan McRae
parent 4311cc3648
commit 5d21b2d44c

View file

@ -76,6 +76,7 @@ static void parse_opts(int argc, char **argv)
config_file = optarg; config_file = optarg;
break; break;
case 'R': case 'R':
free(config->rootdir);
if ((config->rootdir = strdup(optarg)) == NULL) { if ((config->rootdir = strdup(optarg)) == NULL) {
fprintf(stderr, _("error setting rootdir '%s': out of memory\n"), optarg); fprintf(stderr, _("error setting rootdir '%s': out of memory\n"), optarg);
cleanup(); cleanup();