summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2014-10-17 06:11:28 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2014-10-17 06:11:28 +0000
commit74ab8ec010bbb4afe65632fb9c2ff682b8aadd7c (patch)
tree4418e704f7cd0274631b5dc69ab90a24595fbd9a
parent2fc87aaf4f058bd3567ac9f2b5e11fcbd8145b30 (diff)
Remove chunk special-casing malloc(siz) for realloc(NULL, siz). Bit
tricky, but note the remembered size is in bss.
-rw-r--r--usr.sbin/lpr/lpd/lpd.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index badc565111c..f6721e6990d 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lpd.c,v 1.55 2014/10/11 03:01:58 doug Exp $ */
+/* $OpenBSD: lpd.c,v 1.56 2014/10/17 06:11:27 deraadt Exp $ */
/* $NetBSD: lpd.c,v 1.33 2002/01/21 14:42:29 wiz Exp $ */
/*
@@ -154,23 +154,17 @@ main(int argc, char **argv)
switch (i) {
case 'b':
if (blist_addrs >= blist_size) {
- if (blist == NULL) {
- blist_size += sizeof(char *) * 4;
- blist = malloc(blist_size);
- }
- else {
- char **newblist;
- int newblist_size = blist_size +
- sizeof(char *) * 4;
- newblist = realloc(blist, newblist_size);
- if (newblist == NULL) {
- free(blist);
- blist_size = 0;
- blist = NULL;
- }
- blist = newblist;
- blist_size = newblist_size;
+ char **newblist;
+ int newblist_size = blist_size +
+ sizeof(char *) * 4;
+ newblist = realloc(blist, newblist_size);
+ if (newblist == NULL) {
+ free(blist);
+ blist_size = 0;
+ blist = NULL;
}
+ blist = newblist;
+ blist_size = newblist_size;
if (blist == NULL)
err(1, "cant allocate bind addr list");
}