diff udp.c @ 3753:42ed3629601d libavformat

Fix memleak on some OSes in case network initialization fails. See "[PATCH] tcp.c/udp.c memleak?" for discussion.
author rbultje
date Sat, 23 Aug 2008 17:39:56 +0000
parents 8570df039c75
children 8329c0373f69
line wrap: on
line diff
--- a/udp.c	Sat Aug 23 17:39:10 2008 +0000
+++ b/udp.c	Sat Aug 23 17:39:56 2008 +0000
@@ -348,6 +348,9 @@
 
     is_output = (flags & URL_WRONLY);
 
+    if(!ff_network_init())
+        return AVERROR(EIO);
+
     s = av_mallocz(sizeof(UDPContext));
     if (!s)
         return AVERROR(ENOMEM);
@@ -380,9 +383,6 @@
         udp_set_remote_url(h, uri);
     }
 
-    if(!ff_network_init())
-        return AVERROR(EIO);
-
     if (s->is_multicast && !(h->flags & URL_WRONLY))
         s->local_port = port;
     udp_fd = udp_socket_create(s, &my_addr, &len);