Module: libav Branch: master Commit: b380337020e271c5431aa8ef8f8e9dfda5e919b2
Author: James Almer <[email protected]> Committer: Janne Grunau <[email protected]> Date: Mon Jun 8 17:19:25 2015 -0300 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 Signed-off-by: James Almer <[email protected]> Signed-off-by: Janne Grunau <[email protected]> --- libavformat/mpjpegdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c index 72891e7..e2a2ece 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,7 @@ static int mpjpeg_read_probe(AVProbeData *p) break; } } -end: + av_free(pb); return ret; _______________________________________________ libav-commits mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-commits
