Fix memory leak when binding or connecting to bad URL
diff --git a/src/transports/tcp/btcp.c b/src/transports/tcp/btcp.c
index 37541f1..4fe8b58 100644
--- a/src/transports/tcp/btcp.c
+++ b/src/transports/tcp/btcp.c
@@ -118,11 +118,13 @@
     end = addr + strlen (addr);
     pos = strrchr (addr, ':');
     if (pos == NULL) {
+        nn_free (self);
         return -EINVAL;
     }
     ++pos;
     rc = nn_port_resolve (pos, end - pos);
     if (rc < 0) {
+        nn_free (self);
         return -EINVAL;
     }
 
@@ -134,6 +136,7 @@
     /*  Parse the address. */
     rc = nn_iface_resolve (addr, pos - addr - 1, ipv4only, &ss, &sslen);
     if (nn_slow (rc < 0)) {
+        nn_free (self);
         return -ENODEV;
     }
 
@@ -151,6 +154,7 @@
 
     rc = nn_btcp_listen (self);
     if (rc != 0) {
+        // I suspect we might need to do nn_free here.
         return rc;
     }
 
diff --git a/src/transports/tcp/ctcp.c b/src/transports/tcp/ctcp.c
index 8486f2b..fc9bc90 100644
--- a/src/transports/tcp/ctcp.c
+++ b/src/transports/tcp/ctcp.c
@@ -150,10 +150,12 @@
 
     /*  Parse the port. */
     if (!colon) {
+        nn_free (self);
         return -EINVAL;
     }
     rc = nn_port_resolve (colon + 1, end - colon - 1);
     if (rc < 0) {
+        nn_free (self);
         return -EINVAL;
     }
 
@@ -162,6 +164,7 @@
     if (nn_dns_check_hostname (hostname, colon - hostname) < 0 &&
           nn_literal_resolve (hostname, colon - hostname, ipv4only,
           &ss, &sslen) < 0) {
+        nn_free (self);
         return -EINVAL;
     }
 
@@ -169,6 +172,7 @@
     if (semicolon) {
         rc = nn_iface_resolve (addr, semicolon - addr, ipv4only, &ss, &sslen);
         if (rc < 0) {
+            nn_free (self);
             return -ENODEV;
         }
     }