chiark / gitweb /
clients/playrtp.c: Don't crash if an interface has a null address.
[disorder] / clients / playrtp.c
index f6e89d24391a95617bc056445c3ed1ce383a705b..372bfcf63c83373d078011019b89665463e4e2a0 100644 (file)
@@ -500,7 +500,7 @@ struct packet *playrtp_next_packet(void) {
 }
 
 /* display usage message and terminate */
-static void help(void) {
+static void attribute((noreturn)) help(void) {
   xprintf("Usage:\n"
          "  disorder-playrtp [OPTIONS] [[ADDRESS] PORT]\n"
          "Options:\n"
@@ -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;