diff options
author | joerg <joerg> | 2008-08-02 20:33:50 +0000 |
---|---|---|
committer | joerg <joerg> | 2008-08-02 20:33:50 +0000 |
commit | 7be93b44a0d2e33aa0dd07de5f5b673bf95b27c8 (patch) | |
tree | 8901b5966bac844405a560018181d94cc4eccd35 /pkgtools/pkg_install/files/lib/pkg_io.c | |
parent | f3a58140319f67643ea733850de213b695037b07 (diff) | |
download | pkgsrc-7be93b44a0d2e33aa0dd07de5f5b673bf95b27c8.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/lib/pkg_io.c')
-rw-r--r-- | pkgtools/pkg_install/files/lib/pkg_io.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/pkgtools/pkg_install/files/lib/pkg_io.c b/pkgtools/pkg_install/files/lib/pkg_io.c index 8a6eada3a79..2b0c13be733 100644 --- a/pkgtools/pkg_install/files/lib/pkg_io.c +++ b/pkgtools/pkg_install/files/lib/pkg_io.c @@ -1,4 +1,4 @@ -/* $NetBSD: pkg_io.c,v 1.1.2.2 2008/05/21 20:29:24 joerg Exp $ */ +/* $NetBSD: pkg_io.c,v 1.1.2.3 2008/08/02 20:33:50 joerg Exp $ */ /*- * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. * All rights reserved. @@ -36,7 +36,7 @@ #include <sys/cdefs.h> #endif -__RCSID("$NetBSD: pkg_io.c,v 1.1.2.2 2008/05/21 20:29:24 joerg Exp $"); +__RCSID("$NetBSD: pkg_io.c,v 1.1.2.3 2008/08/02 20:33:50 joerg Exp $"); #include <archive.h> #include <archive_entry.h> @@ -94,9 +94,7 @@ open_archive_by_url(struct url *url, void **cookie) struct fetch_archive *f; struct archive *a; - f = malloc(sizeof(*f)); - if (f == NULL) - err(2, "cannot allocate memory for remote archive"); + f = xmalloc(sizeof(*f)); f->url = url; a = archive_read_new(); @@ -185,10 +183,7 @@ find_best_package(struct url *url, const char *pattern, struct url **best_url) (pattern[i]) != '-') break; } - if (asprintf(&url_pattern, "%*.*s*", (int)i, (int)i, pattern) == -1) { - free(best_match); - return -1; - } + url_pattern = xasprintf("%*.*s*", (int)i, (int)i, pattern); fetchInitURLList(&ue); if (fetchList(&ue, url, url_pattern, "")) { |