aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2017-02-20 02:11:58 +0100
committerLuca Barbato <lu_zero@gentoo.org>2017-02-27 13:51:53 +0100
commit5263f464db5f2df74ddf712f6d1221b24475fa8e (patch)
treeaf6ce1dff9caeb0d5a2374384a8f54c5c26f913b
parentb9b82151a1aaa8bbf389853a6142c4e101d80b86 (diff)
downloadffmpeg-5263f464db5f2df74ddf712f6d1221b24475fa8e.tar.gz
rtsp: Lazily allocate the pollfd array
And use av_malloc_array.
-rw-r--r--libavformat/rtsp.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index e4cbae43a2..4ff12c63dd 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -662,7 +662,6 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
int ff_sdp_parse(AVFormatContext *s, const char *content)
{
- RTSPState *rt = s->priv_data;
const char *p;
int letter, i;
/* Some SDP lines, particularly for Realmedia or ASF RTSP streams,
@@ -709,8 +708,6 @@ int ff_sdp_parse(AVFormatContext *s, const char *content)
av_free(s1->default_exclude_source_addrs[i]);
av_freep(&s1->default_exclude_source_addrs);
- rt->p = av_malloc(sizeof(struct pollfd)*2*(rt->nb_rtsp_streams+1));
- if (!rt->p) return AVERROR(ENOMEM);
return 0;
}
#endif /* CONFIG_RTPDEC */
@@ -1920,6 +1917,12 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
struct pollfd *p = rt->p;
int *fds = NULL, fdsnum, fdsidx;
+ if (!p) {
+ p = rt->p = av_malloc_array(2 * (rt->nb_rtsp_streams + 1), sizeof(struct pollfd));
+ if (!p)
+ return AVERROR(ENOMEM);
+ }
+
if (rt->rtsp_hd) {
tcp_fd = ffurl_get_file_handle(rt->rtsp_hd);
p[max_p].fd = tcp_fd;