]> git.meshlink.io Git - meshlink/blobdiff - src/net_packet.c
Fix a memory leak.
[meshlink] / src / net_packet.c
index ce1eb62680bd1c25fcb2038dc50892069ab21cce..02a617d1922bfae065a41539b14ddedec707964e 100644 (file)
@@ -339,8 +339,11 @@ static void choose_udp_address(meshlink_handle_t *mesh, const node_t *n, const s
                        *port++ = 0;
                        *sa_buf = str2sockaddr_random(mesh, host, port);
                        *sa = sa_buf;
-                       free(host);
-                       goto check_socket;
+
+                       if(sa_buf->sa.sa_family != AF_UNKNOWN) {
+                               free(host);
+                               goto check_socket;
+                       }
                }
 
                free(host);