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 <jamrial@gmail.com> Signed-off-by: Janne Grunau <janne-libav@jannau.net>
This commit is contained in:
parent
210921722b
commit
b380337020
@ -83,13 +83,13 @@ static int mpjpeg_read_probe(AVProbeData *p)
|
|||||||
char line[128] = { 0 };
|
char line[128] = { 0 };
|
||||||
int ret = 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);
|
pb = avio_alloc_context(p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL);
|
||||||
if (!pb)
|
if (!pb)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-')
|
|
||||||
goto end;
|
|
||||||
|
|
||||||
while (!pb->eof_reached) {
|
while (!pb->eof_reached) {
|
||||||
ret = get_line(pb, line, sizeof(line));
|
ret = get_line(pb, line, sizeof(line));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -101,7 +101,7 @@ static int mpjpeg_read_probe(AVProbeData *p)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end:
|
|
||||||
av_free(pb);
|
av_free(pb);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user