mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
avformat/libsrt: fix cleanups on failed libsrt_open() and libsrt_setup()
- Call srt_epoll_release() to avoid fd leak on libsrt_setup() error. - Call srt_cleanup() on libsrt_open() failure. - Fix return value and method on mode parsing failure. Based on a patch by Nicolas Sugino <nsugino@3way.com.ar>. Signed-off-by: Marton Balint <cus@passwd.hu> (cherry picked from commit fb0304fcc9f79a4c9cbdf347f20f484529f169ba)
This commit is contained in:
parent
8a2acdc6da
commit
074b2032e6
@ -373,11 +373,6 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags)
|
|||||||
int64_t open_timeout = 0;
|
int64_t open_timeout = 0;
|
||||||
int eid;
|
int eid;
|
||||||
|
|
||||||
eid = srt_epoll_create();
|
|
||||||
if (eid < 0)
|
|
||||||
return libsrt_neterrno(h);
|
|
||||||
s->eid = eid;
|
|
||||||
|
|
||||||
av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
|
av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
|
||||||
&port, path, sizeof(path), uri);
|
&port, path, sizeof(path), uri);
|
||||||
if (strcmp(proto, "srt"))
|
if (strcmp(proto, "srt"))
|
||||||
@ -413,6 +408,11 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags)
|
|||||||
|
|
||||||
cur_ai = ai;
|
cur_ai = ai;
|
||||||
|
|
||||||
|
eid = srt_epoll_create();
|
||||||
|
if (eid < 0)
|
||||||
|
return libsrt_neterrno(h);
|
||||||
|
s->eid = eid;
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
|
|
||||||
fd = srt_socket(cur_ai->ai_family, cur_ai->ai_socktype, 0);
|
fd = srt_socket(cur_ai->ai_family, cur_ai->ai_socktype, 0);
|
||||||
@ -495,6 +495,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags)
|
|||||||
if (listen_fd >= 0)
|
if (listen_fd >= 0)
|
||||||
srt_close(listen_fd);
|
srt_close(listen_fd);
|
||||||
freeaddrinfo(ai);
|
freeaddrinfo(ai);
|
||||||
|
srt_epoll_release(s->eid);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,7 +585,8 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
|
|||||||
} else if (!strcmp(buf, "rendezvous")) {
|
} else if (!strcmp(buf, "rendezvous")) {
|
||||||
s->mode = SRT_MODE_RENDEZVOUS;
|
s->mode = SRT_MODE_RENDEZVOUS;
|
||||||
} else {
|
} else {
|
||||||
return AVERROR(EIO);
|
ret = AVERROR(EINVAL);
|
||||||
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (av_find_info_tag(buf, sizeof(buf), "sndbuf", p)) {
|
if (av_find_info_tag(buf, sizeof(buf), "sndbuf", p)) {
|
||||||
@ -632,10 +634,15 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
|
|||||||
s->linger = strtol(buf, NULL, 10);
|
s->linger = strtol(buf, NULL, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return libsrt_setup(h, uri, flags);
|
ret = libsrt_setup(h, uri, flags);
|
||||||
|
if (ret < 0)
|
||||||
|
goto err;
|
||||||
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
av_freep(&s->smoother);
|
av_freep(&s->smoother);
|
||||||
av_freep(&s->streamid);
|
av_freep(&s->streamid);
|
||||||
|
srt_cleanup();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user