diff options
author | dougb <dougb@FreeBSD.org> | 2011-07-16 10:49:33 +0000 |
---|---|---|
committer | dougb <dougb@FreeBSD.org> | 2011-07-16 10:49:33 +0000 |
commit | 387965661eaa775833b1e35b917f8e568ab7f5c6 (patch) | |
tree | cb160fa2acd93f24b5f5b9082cd3afc68396d51a /lib/dns/rdataslab.c | |
parent | 499bf45e8f8ff10f88039acf04ae14976333a979 (diff) | |
download | FreeBSD-src-387965661eaa775833b1e35b917f8e568ab7f5c6.zip FreeBSD-src-387965661eaa775833b1e35b917f8e568ab7f5c6.tar.gz |
Vendor import of BIND 9.8.0-P4
Diffstat (limited to 'lib/dns/rdataslab.c')
-rw-r--r-- | lib/dns/rdataslab.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c index d1a02a0..932f8de 100644 --- a/lib/dns/rdataslab.c +++ b/lib/dns/rdataslab.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdataslab.c,v 1.48.50.4 2010-02-25 10:56:41 tbox Exp $ */ +/* $Id: rdataslab.c,v 1.52.148.1.2.1 2011-06-02 23:47:35 tbox Exp $ */ /*! \file */ @@ -144,21 +144,25 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, nalloc = dns_rdataset_count(rdataset); nitems = nalloc; - if (nitems == 0) + if (nitems == 0 && rdataset->type != 0) return (ISC_R_FAILURE); if (nalloc > 0xffff) return (ISC_R_NOSPACE); - x = isc_mem_get(mctx, nalloc * sizeof(struct xrdata)); - if (x == NULL) - return (ISC_R_NOMEMORY); + + if (nalloc != 0) { + x = isc_mem_get(mctx, nalloc * sizeof(struct xrdata)); + if (x == NULL) + return (ISC_R_NOMEMORY); + } else + x = NULL; /* * Save all of the rdata members into an array. */ result = dns_rdataset_first(rdataset); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS && result != ISC_R_NOMORE) goto free_rdatas; for (i = 0; i < nalloc && result == ISC_R_SUCCESS; i++) { INSIST(result == ISC_R_SUCCESS); @@ -223,11 +227,14 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, /* * Don't forget the last item! */ + if (nalloc != 0) { #if DNS_RDATASET_FIXED - buflen += (8 + x[i-1].rdata.length); + buflen += (8 + x[i-1].rdata.length); #else - buflen += (2 + x[i-1].rdata.length); + buflen += (2 + x[i-1].rdata.length); #endif + } + /* * Provide space to store the per RR meta data. */ @@ -316,7 +323,8 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, result = ISC_R_SUCCESS; free_rdatas: - isc_mem_put(mctx, x, nalloc * sizeof(struct xrdata)); + if (x != NULL) + isc_mem_put(mctx, x, nalloc * sizeof(struct xrdata)); return (result); } |