summaryrefslogtreecommitdiff
path: root/pkgtools/pkg_install/files/admin/main.c
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2008-08-02 20:33:50 +0000
committerjoerg <joerg@pkgsrc.org>2008-08-02 20:33:50 +0000
commit2d14d746c33ed096821a94626a0607aa53d26fe9 (patch)
tree8901b5966bac844405a560018181d94cc4eccd35 /pkgtools/pkg_install/files/admin/main.c
parent3e4bed6c122de22806583e1d7904c4f0e9a71d46 (diff)
downloadpkgsrc-2d14d746c33ed096821a94626a0607aa53d26fe9.tar.gz
Most memory allocation failures were fatal already and the majority of
the rest lacked an explicit check. Add the usual x* wrappers around malloc and friends that explicitly terminate on error and use them in all but Dewey.
Diffstat (limited to 'pkgtools/pkg_install/files/admin/main.c')
-rw-r--r--pkgtools/pkg_install/files/admin/main.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/pkgtools/pkg_install/files/admin/main.c b/pkgtools/pkg_install/files/admin/main.c
index 515795a7926..19cb7bfc8d6 100644
--- a/pkgtools/pkg_install/files/admin/main.c
+++ b/pkgtools/pkg_install/files/admin/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.42.2.5 2008/06/04 11:23:13 joerg Exp $ */
+/* $NetBSD: main.c,v 1.42.2.6 2008/08/02 20:33:50 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -8,7 +8,7 @@
#include <sys/cdefs.h>
#endif
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.42.2.5 2008/06/04 11:23:13 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.42.2.6 2008/08/02 20:33:50 joerg Exp $");
#endif
/*-
@@ -660,7 +660,7 @@ set_unset_variable(char **argv, Boolean unset)
if ((eq=strchr(argv[0], '=')) == NULL)
usage();
- variable = malloc(eq-argv[0]+1);
+ variable = xmalloc(eq-argv[0]+1);
strlcpy(variable, argv[0], eq-argv[0]+1);
arg.variable = variable;
@@ -692,8 +692,7 @@ set_unset_variable(char **argv, Boolean unset)
warnx("no matching pkg for `%s'", *argv);
ret++;
} else {
- if (asprintf(&pattern, "%s-[0-9]*", *argv) == -1)
- errx(EXIT_FAILURE, "asprintf failed");
+ pattern = xasprintf("%s-[0-9]*", *argv);
if (match_installed_pkgs(pattern, set_installed_info_var, &arg) == -1)
errx(EXIT_FAILURE, "Cannot process pkdbdb");