[FFmpeg-devel] [PATCH] avformat/libsrt: Fix epoll fd leak
Nicolas Sugino
nsugino at 3way.com.ar
Wed Aug 26 07:02:57 EEST 2020
Call srt_epoll_release() to avoid fd leak on libsrt_open() error.
---
libavformat/libsrt.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index 4025b24976..6da372081e 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -380,10 +380,13 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags)
av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
&port, path, sizeof(path), uri);
- if (strcmp(proto, "srt"))
+ if (strcmp(proto, "srt")) {
+ srt_epoll_release(s->eid);
return AVERROR(EINVAL);
+ }
if (port <= 0 || port >= 65536) {
av_log(h, AV_LOG_ERROR, "Port missing in uri\n");
+ srt_epoll_release(s->eid);
return AVERROR(EINVAL);
}
p = strchr(uri, '?');
@@ -408,6 +411,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags)
av_log(h, AV_LOG_ERROR,
"Failed to resolve hostname %s: %s\n",
hostname, gai_strerror(ret));
+ srt_epoll_release(s->eid);
return AVERROR(EIO);
}
@@ -495,6 +499,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags)
if (listen_fd >= 0)
srt_close(listen_fd);
freeaddrinfo(ai);
+ srt_epoll_release(s->eid);
return ret;
}
@@ -632,10 +637,16 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
s->linger = strtol(buf, NULL, 10);
}
}
- return libsrt_setup(h, uri, flags);
+ ret = libsrt_setup(h, uri, flags);
+ if (ret) {
+ goto err;
+ }
+ return 0;
+
err:
av_freep(&s->smoother);
av_freep(&s->streamid);
+ srt_cleanup();
return ret;
}
--
2.17.1
More information about the ffmpeg-devel
mailing list