From: William King Date: Sat, 25 May 2013 14:36:43 +0000 (-0700) Subject: Better to not pass tmp_socket to setsockopt if there was an error here creating the... X-Git-Tag: v1.2.13~324 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=782480c48be1ffa84aab7eddc629cf00c00ca984;p=thirdparty%2Ffreeswitch.git Better to not pass tmp_socket to setsockopt if there was an error here creating the socket. --- diff --git a/src/switch_utils.c b/src/switch_utils.c index 146e34d6fc..77f38badbe 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -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;