From 531074d11aa851d04f7a120882cacd2dcbf98cfe Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Thu, 26 May 2016 21:29:54 -0700 Subject: [PATCH] [master] fixed some test failures --- lib/dns/ipkeylist.c | 11 ++++++++--- lib/isc/buffer.c | 10 +++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/dns/ipkeylist.c b/lib/dns/ipkeylist.c index c70c1dc837..fef2925eeb 100644 --- a/lib/dns/ipkeylist.c +++ b/lib/dns/ipkeylist.c @@ -30,16 +30,19 @@ dns_ipkeylist_clear(isc_mem_t *mctx, dns_ipkeylist_t *ipkl) { isc_uint32_t i; REQUIRE(ipkl != NULL); - REQUIRE(ipkl->addrs != NULL); - REQUIRE(ipkl->keys != NULL); + REQUIRE(ipkl->count == 0 || ipkl->keys != NULL); if (ipkl->count == 0) return; - isc_mem_put(mctx, ipkl->addrs, ipkl->count * sizeof(isc_sockaddr_t)); + if (ipkl != NULL) + isc_mem_put(mctx, ipkl->addrs, + ipkl->count * sizeof(isc_sockaddr_t)); + if (ipkl->dscps != NULL) isc_mem_put(mctx, ipkl->dscps, ipkl->count * sizeof(isc_dscp_t)); + for (i = 0; i < ipkl->count; i++) { if (ipkl->keys[i] == NULL) continue; @@ -47,7 +50,9 @@ dns_ipkeylist_clear(isc_mem_t *mctx, dns_ipkeylist_t *ipkl) { dns_name_free(ipkl->keys[i], mctx); isc_mem_put(mctx, ipkl->keys[i], sizeof(dns_name_t)); } + isc_mem_put(mctx, ipkl->keys, ipkl->count * sizeof(dns_name_t *)); + ipkl->count = 0; ipkl->addrs = NULL; ipkl->dscps = NULL; diff --git a/lib/isc/buffer.c b/lib/isc/buffer.c index 8eb75e9b36..c8cbdd5a5d 100644 --- a/lib/isc/buffer.c +++ b/lib/isc/buffer.c @@ -60,7 +60,7 @@ isc_buffer_reinit(isc_buffer_t *b, void *base, unsigned int length) { */ REQUIRE(b->length <= length); REQUIRE(base != NULL); - REQUIRE(b->autore = ISC_FALSE); + REQUIRE(!b->autore); (void)memmove(base, b->base, b->length); b->base = base; @@ -372,7 +372,7 @@ void isc__buffer_putuint32(isc_buffer_t *b, isc_uint32_t val) { isc_result_t result; REQUIRE(ISC_BUFFER_VALID(b)); - if (b->autore == ISC_TRUE) { + if (b->autore) { result = isc_buffer_reserve(&b, 4); REQUIRE(result == ISC_R_SUCCESS); } @@ -413,7 +413,7 @@ isc__buffer_putuint48(isc_buffer_t *b, isc_uint64_t val) { isc_uint32_t vallo; REQUIRE(ISC_BUFFER_VALID(b)); - if (b->autore == ISC_TRUE) { + if (b->autore) { result = isc_buffer_reserve(&b, 6); REQUIRE(result == ISC_R_SUCCESS); } @@ -431,7 +431,7 @@ isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base, { isc_result_t result; REQUIRE(ISC_BUFFER_VALID(b)); - if (b->autore == ISC_TRUE) { + if (b->autore) { result = isc_buffer_reserve(&b, length); REQUIRE(result == ISC_R_SUCCESS); } @@ -453,7 +453,7 @@ isc__buffer_putstr(isc_buffer_t *b, const char *source) { * Do not use ISC__BUFFER_PUTSTR(), so strlen is only done once. */ l = strlen(source); - if (b->autore == ISC_TRUE) { + if (b->autore) { result = isc_buffer_reserve(&b, l); REQUIRE(result == ISC_R_SUCCESS); }