chiark / gitweb /
clients/playrtp.c: Don't crash if an interface has a null address.
[disorder] / clients / playrtp.c
index d28369fb5b5293195c0e9bab73d81476957b6b10..372bfcf63c83373d078011019b89665463e4e2a0 100644 (file)
@@ -795,6 +795,12 @@ int main(int argc, char **argv) {
   struct sockaddr *addr;
   socklen_t addr_len;
   if(!strcmp(sl.s[0], "-")) {
+    /* We'll need a connection to request the incoming stream, so open one if
+     * we don't have one already */
+    if(!c) {
+      if(!(c = disorder_new(1))) exit(EXIT_FAILURE);
+      if(disorder_connect(c)) exit(EXIT_FAILURE);
+    }
     /* Pick address family to match known-working connectivity to the server */
     int family = disorder_client_af(c);
     /* Get a list of interfaces */
@@ -803,6 +809,7 @@ int main(int argc, char **argv) {
       disorder_fatal(errno, "error calling getifaddrs");
     /* Try to pick a good one */
     for(; ifa; ifa = ifa->ifa_next) {
+      if(!ifa->ifa_addr) continue;
       if(bestifa == NULL
          || compare_interfaces(ifa, bestifa, family) > 0)
         bestifa = ifa;