]> git.sesse.net Git - ffmpeg/commitdiff
udp: Fix crashes after adding AVOptions
authorMartin Storsjö <martin@martin.st>
Thu, 19 Mar 2015 07:28:25 +0000 (09:28 +0200)
committerMartin Storsjö <martin@martin.st>
Thu, 19 Mar 2015 08:25:22 +0000 (10:25 +0200)
Add a missing AVClass member, check whether localaddr is null.
(Previously, localaddr was always a local stack buffer, while it
now also can be an avoption string which can be null.)

This fixes crashes when not passing any localaddr parameter, since
66028b7ba.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/udp.c

index e175a4b541cbbb2f81a0438c69f598fea76dedc5..321ed299019db149c7f86ba02590a9b4a0d26bd2 100644 (file)
@@ -42,6 +42,7 @@
 #endif
 
 typedef struct UDPContext {
+    const AVClass *class;
     int udp_fd;
     int ttl;
     int buffer_size;
@@ -293,7 +294,7 @@ static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr,
 
     if (((struct sockaddr *) &s->dest_addr)->sa_family)
         family = ((struct sockaddr *) &s->dest_addr)->sa_family;
-    res0 = udp_resolve_host(localaddr[0] ? localaddr : NULL, s->local_port,
+    res0 = udp_resolve_host((localaddr && localaddr[0]) ? localaddr : NULL, s->local_port,
                             SOCK_DGRAM, family, AI_PASSIVE);
     if (res0 == 0)
         goto fail;