summaryrefslogtreecommitdiff
path: root/libavformat/libsrt.c
diff options
context:
space:
mode:
authorSteven Liu <lq@chinaffmpeg.org>2019-10-10 10:43:58 +0800
committerSteven Liu <lq@chinaffmpeg.org>2019-10-19 06:49:46 +0200
commit1f7b527194a2a10c334b0ff66ec0a72f4fe65e08 (patch)
treee517afd0da50934e51646b2de74f60a616c42ebf /libavformat/libsrt.c
parent17d96c15d25e0998770f36e6f93d01014dd65f6c (diff)
avformat/libsrt: check av_strdup() return value and fix memleak
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavformat/libsrt.c')
-rw-r--r--libavformat/libsrt.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index b5568089fa..1c34ec50b2 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -478,6 +478,7 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
SRTContext *s = h->priv_data;
const char * p;
char buf[256];
+ int ret = 0;
if (srt_startup() < 0) {
return AVERROR_UNKNOWN;
@@ -564,10 +565,18 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
if (av_find_info_tag(buf, sizeof(buf), "streamid", p)) {
av_freep(&s->streamid);
s->streamid = av_strdup(buf);
+ if (!s->streamid) {
+ ret = AVERROR(ENOMEM);
+ goto err;
+ }
}
if (av_find_info_tag(buf, sizeof(buf), "smoother", p)) {
av_freep(&s->smoother);
s->smoother = av_strdup(buf);
+ if(!s->smoother) {
+ ret = AVERROR(ENOMEM);
+ goto err;
+ }
}
if (av_find_info_tag(buf, sizeof(buf), "messageapi", p)) {
s->messageapi = strtol(buf, NULL, 10);
@@ -578,11 +587,16 @@ static int libsrt_open(URLContext *h, const char *uri, int flags)
} else if (!strcmp(buf, "file")) {
s->transtype = SRTT_FILE;
} else {
- return AVERROR(EINVAL);
+ ret = AVERROR(EINVAL);
+ goto err;
}
}
}
return libsrt_setup(h, uri, flags);
+err:
+ av_freep(&s->smoother);
+ av_freep(&s->streamid);
+ return ret;
}
static int libsrt_read(URLContext *h, uint8_t *buf, int size)