diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-10-17 06:11:28 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-10-17 06:11:28 +0000 |
commit | 74ab8ec010bbb4afe65632fb9c2ff682b8aadd7c (patch) | |
tree | 4418e704f7cd0274631b5dc69ab90a24595fbd9a /usr.sbin/lpr/lpd | |
parent | 2fc87aaf4f058bd3567ac9f2b5e11fcbd8145b30 (diff) |
Remove chunk special-casing malloc(siz) for realloc(NULL, siz). Bit
tricky, but note the remembered size is in bss.
Diffstat (limited to 'usr.sbin/lpr/lpd')
-rw-r--r-- | usr.sbin/lpr/lpd/lpd.c | 28 |
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"); } |