]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Better to not pass tmp_socket to setsockopt if there was an error here creating the...
authorWilliam King <william.king@quentustech.com>
Sat, 25 May 2013 14:36:43 +0000 (07:36 -0700)
committerWilliam King <william.king@quentustech.com>
Sat, 25 May 2013 14:36:43 +0000 (07:36 -0700)
src/switch_utils.c

index 146e34d6fc1b07df0650d5e89fc39b4a7a02ba33..77f38badbec0199d3bde08c736494a8157eecd6d 100644 (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;