]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/tcp.c
return error if frame_offset is negative, prevent segfault
[ffmpeg] / libavformat / tcp.c
index 2d417ecc478ea4e7f0edbaeda81e6390b98b8fef..6c25e72b6f1d52215cc45654150a497c2e19b35c 100644 (file)
@@ -21,6 +21,7 @@
 #include "avformat.h"
 #include <unistd.h>
 #include "network.h"
+#include "os_support.h"
 #include <sys/time.h>
 
 typedef struct TCPContext {
@@ -49,10 +50,14 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
     if (!s)
         return AVERROR(ENOMEM);
     h->priv_data = s;
+    h->is_streamed = 1;
 
     if (port <= 0 || port >= 65536)
         goto fail;
 
+    if(!ff_network_init())
+        return AVERROR(EIO);
+
     dest_addr.sin_family = AF_INET;
     dest_addr.sin_port = htons(port);
     if (resolve_host(&dest_addr.sin_addr, hostname) < 0)
@@ -174,6 +179,7 @@ static int tcp_close(URLContext *h)
 {
     TCPContext *s = h->priv_data;
     closesocket(s->fd);
+    ff_network_close();
     av_free(s);
     return 0;
 }