[pacman-dev,2/7] pacman-conf: free rootdir before replacing

Message ID 20210116072101.38203-2-andrew.gregory.8@gmail.com
State New
Headers show
Series [pacman-dev,1/7] pacman: indicate --overwrite takes a glob | expand

Commit Message

Andrew Gregory Jan. 16, 2021, 7:20 a.m. UTC
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
---
 src/pacman/pacman-conf.c | 1 +
 1 file changed, 1 insertion(+)

Patch

diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 463badf1..05492ed9 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -76,6 +76,7 @@  static void parse_opts(int argc, char **argv)
 				config_file = optarg;
 				break;
 			case 'R':
+				free(config->rootdir);
 				if ((config->rootdir = strdup(optarg)) == NULL) {
 					fprintf(stderr, _("error setting rootdir '%s': out of memory\n"), optarg);
 					cleanup();