summaryrefslogtreecommitdiff
path: root/libavformat/mpjpegdec.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2015-06-08 17:39:38 -0300
committerJames Almer <jamrial@gmail.com>2015-06-08 18:26:42 -0300
commit1382add59df149193620ca0714ceac0929208c88 (patch)
tree7771b73f8245d1be1e46414d135154139369e56a /libavformat/mpjpegdec.c
parentd5a645625d876288021d8192e4e3199087a753fc (diff)
downloadffmpeg-1382add59df149193620ca0714ceac0929208c88.tar.gz
mpjpegdec: don't try to alloc an AVIOContext when probe is guaranteed to fail
The first check is done without the AVIOContext, so alloc it only if said check succeeds Reviewed-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/mpjpegdec.c')
-rw-r--r--libavformat/mpjpegdec.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c
index 56fe159915..845e95cb74 100644
--- a/libavformat/mpjpegdec.c
+++ b/libavformat/mpjpegdec.c
@@ -83,13 +83,13 @@ static int mpjpeg_read_probe(AVProbeData *p)
char line[128] = { 0 };
int ret = 0;
+ if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-')
+ return 0;
+
pb = avio_alloc_context(p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL);
if (!pb)
return AVERROR(ENOMEM);
- if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-')
- goto end;
-
while (!pb->eof_reached) {
ret = get_line(pb, line, sizeof(line));
if (ret < 0)
@@ -101,7 +101,6 @@ static int mpjpeg_read_probe(AVProbeData *p)
break;
}
}
-end:
av_free(pb);