Better to not pass tmp_socket to setsockopt if there was an error here creating the socket.

This commit is contained in:
William King 2013-05-25 07:36:43 -07:00
parent 479a06bda6
commit 782480c48b
1 changed files with 6 additions and 2 deletions

View File

@ -1490,7 +1490,9 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int *ma
remote.sin_port = htons(4242);
memset(&iface_out, 0, sizeof(iface_out));
tmp_socket = socket(AF_INET, SOCK_DGRAM, 0);
if ( (tmp_socket = socket(AF_INET, SOCK_DGRAM, 0)) == -1 ) {
goto doh;
}
if (setsockopt(tmp_socket, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) == -1) {
goto doh;
@ -1528,7 +1530,9 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int *ma
remote.sin6_port = htons(4242);
memset(&iface_out, 0, sizeof(iface_out));
tmp_socket = socket(AF_INET6, SOCK_DGRAM, 0);
if ( (tmp_socket = socket(AF_INET6, SOCK_DGRAM, 0)) == -1 ) {
goto doh;
}
if (connect(tmp_socket, (struct sockaddr *) &remote, sizeof(remote)) == -1) {
goto doh;