summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvy Foster <iff@escondida.tk>2018-02-17 02:10:57 +0100
committerAllan McRae <allan@archlinux.org>2018-03-14 03:16:58 +0100
commitc968e625e84c1dfa9a5f49e816a7969b66fd148c (patch)
tree80d35b0f12f45aa2a12ddba8d23e98c13312c50f
parent0e260f9335546d5834eb3e1d37cd23bc72765162 (diff)
downloadpacman-c968e625e84c1dfa9a5f49e816a7969b66fd148c.tar.gz
pacman-c968e625e84c1dfa9a5f49e816a7969b66fd148c.tar.xz
pacman-conf.c: exit if cannot set rootdir or parse config file
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--src/pacman/pacman-conf.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index 4ffa24a3..aa0cdf22 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -77,7 +77,11 @@ static void parse_opts(int argc, char **argv)
config_file = optarg;
break;
case 'R':
- config->rootdir = strdup(optarg);
+ if ((config->rootdir = strdup(optarg)) == NULL) {
+ fprintf(stderr, "error setting rootdir '%s': out of memory\n", optarg);
+ cleanup();
+ exit(1);
+ }
break;
case 'l':
repo_list = 1;
@@ -105,6 +109,8 @@ static void parse_opts(int argc, char **argv)
if(parseconfigfile(config_file) != 0 || setdefaults(config) != 0) {
fprintf(stderr, "error parsing '%s'\n", config_file);
+ cleanup();
+ exit(1);
}
}