Cppcheck found a few possible memory leaks and a couple of possible null
pointer derefs.  I have gone through the code and verified none of these 
are security issues:

* DwDnsStr.c: Memory leak only if malloc() were to fail
* DwRecurse.c: Null pointer dereference if malloc() were to fail
* DwUdpSocket.c: Added check to see if pointer (that is never NULL) is NULL
* DwHash.c: Closing single open file descriptor
* DwStr.c: Memory leak if string over 16 megabytes in size requested
* DwSys.c: malloc() failure issue; only present if -DVALGRIND_NOERRORS used

--- deadwood-3.2.04/src/DwDnsStr.c	2013-12-20 07:48:11.000000000 -0800
+++ deadwood-3.2.05/src/DwDnsStr.c	2014-01-08 11:19:29.000000000 -0800
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2013 Sam Trenholme
+/* Copyright (c) 2009-2014 Sam Trenholme
  *
  * TERMS
  *
@@ -36,8 +36,11 @@
         int a;
 
         out = dw_malloc(sizeof(dns_string));
-        if(out == 0 || ancount < 0 || nscount < 0 || arcount < 0) {
-                return 0;
+	if(out == 0) {
+		return 0;
+	}
+        if(ancount < 0 || nscount < 0 || arcount < 0) {
+                goto catch_dwc_init_dns_str;
         }
         out->an = dw_malloc((ancount * sizeof(uint16_t) * 2) + 2);
         if(out->an != 0) {
@@ -45,7 +48,7 @@
                         out->an[a] = 0;
                 }
         } else if(ancount > 0) {
-                return 0;
+                goto catch_dwc_init_dns_str;
         }
         out->ns = dw_malloc((nscount * sizeof(uint16_t) * 2) + 2);
         if(out->ns != 0) {
@@ -53,7 +56,7 @@
                         out->ns[a] = 0;
                 }
         } else if(nscount > 0) {
-                return 0;
+                goto catch_dwc_init_dns_str;
         }
         out->ar = dw_malloc((arcount * sizeof(uint16_t) * 2) + 2);
         if(out->ar != 0) {
@@ -61,7 +64,7 @@
                         out->ar[a] = 0;
                 }
         } else if(arcount > 0) {
-                return 0;
+                goto catch_dwc_init_dns_str;
         }
         out->packet = 0;
         out->ancount = ancount;
@@ -86,6 +89,7 @@
         if(out->ar != 0) {
                 free(out->ar);
         }
+	free(out);
         return 0;
 }
 
--- deadwood-3.2.04/src/DwRecurse.c	2013-12-20 07:48:10.000000000 -0800
+++ deadwood-3.2.05/src/DwRecurse.c	2014-01-08 11:21:32.000000000 -0800
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2013 Sam Trenholme
+/* Copyright (c) 2009-2014 Sam Trenholme
  *
  * TERMS
  *
@@ -1782,8 +1782,11 @@
                 goto catch_dwx_make_one_cname_rr;
         }
         out = dw_copy(temp);
+	if(out == 0) {
+                goto catch_dwx_make_one_cname_rr;
+        }
         *len = out->len; /* Length of first dlabel */
-        if(out == 0 || dw_put_u16(out,RR_CNAME,-1) == -1 ||
+        if(dw_put_u16(out,RR_CNAME,-1) == -1 ||
                         dw_put_u16(out,1,-1) == -1 /* CLASS */ ||
                         dw_put_u16(out,(ttl >> 16) & 0xffff, -1) == -1 ||
                         dw_put_u16(out,(ttl & 0xffff), -1) == -1) {
--- deadwood-3.2.04/src/DwUdpSocket.c	2013-12-20 07:48:11.000000000 -0800
+++ deadwood-3.2.05/src/DwUdpSocket.c	2014-01-08 11:24:21.000000000 -0800
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2013 Sam Trenholme and others
+/* Copyright (c) 2007-2014 Sam Trenholme and others
  *
  * TERMS
  *
@@ -530,6 +530,10 @@
         socklen_t c_len = sizeof(struct sockaddr_in);
         int ret = -1, type = 0, cache_type = 0;
 
+	if(client == 0) {
+		goto catch_get_reply_from_cache;
+	}
+
 #ifdef IPV6
         if (client->Family == AF_INET6) {
                c_len = sizeof(struct sockaddr_in6);
--- deadwood-3.2.04/src/DwHash.c	2013-12-20 07:48:11.000000000 -0800
+++ deadwood-3.2.05/src/DwHash.c	2014-01-08 11:36:31.000000000 -0800
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2012 Sam Trenholme
+/* Copyright (c) 2007-2014 Sam Trenholme
  *
  * TERMS
  *
@@ -88,6 +88,7 @@
         add_constant ^= dwr_rng(quick_n_dirty);
         add_constant ^= (dwr_rng(quick_n_dirty) << 15);
         dwr_zap(quick_n_dirty);
+	fclose(in);
 
         return;
 
@@ -95,6 +96,9 @@
 #ifndef MINGW
         printf("Warning: Can not set add_constant\n");
 #endif
+	if(in != 0) {
+		fclose(in);		
+	}
         return;
 }
 
--- deadwood-3.2.04/src/DwStr.c	2013-12-20 07:48:11.000000000 -0800
+++ deadwood-3.2.05/src/DwStr.c	2014-01-08 11:47:18.000000000 -0800
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2013 Sam Trenholme
+/* Copyright (c) 2007-2014 Sam Trenholme
  *
  * TERMS
  *
@@ -54,6 +54,7 @@
                            * exit(1) here */
         }
         if(size >= 134217728 /* 2 ** 27 */) {
+                free(new);
                 return 0;
         }
         /* 2 byte cushion to avoid off-by-one security problems */
--- deadwood-3.2.04/src/DwSys.c	2013-12-20 07:48:11.000000000 -0800
+++ deadwood-3.2.05/src/DwSys.c	2014-01-08 11:48:13.000000000 -0800
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2012 Sam Trenholme
+/* Copyright (c) 2007-2014 Sam Trenholme
  *
  * TERMS
  *
@@ -611,15 +611,15 @@
         pid_t pnum = 1;
 
         noise = (uint8_t *)dw_malloc(512);
+        if(noise == 0) {
+                dw_fatal("error allocating memory for noise");
+        }
 #ifdef VALGRIND_NOERRORS
         /* Valgrind reports our intentional use of values of uncleared
          * allocated memory as one source of entropy as an error, so we
          * allow it to be disabled for Valgrind testing */
-        memset(noise,0,512);
+       	memset(noise,0,512);
 #endif /* VALGRIND_NOERRORS */
-        if(noise == 0) {
-                dw_fatal("error allocating memory for noise");
-        }
 
         get_entropy_from_seedfile(noise,256);
 
