mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
avformat/mpjpegdec: Avoid allocation of AVIOContext
Put an AVIOContext whose lifetime doesn't extend beyond the function where it is allocated on the stack instead of allocating and freeing it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
5f758c31f9
commit
670fd3b0ec
@ -113,20 +113,16 @@ static int mpjpeg_read_close(AVFormatContext *s)
|
|||||||
|
|
||||||
static int mpjpeg_read_probe(const AVProbeData *p)
|
static int mpjpeg_read_probe(const AVProbeData *p)
|
||||||
{
|
{
|
||||||
AVIOContext *pb;
|
AVIOContext pb;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-')
|
if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-')
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pb = avio_alloc_context(p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL);
|
ffio_init_context(&pb, p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL);
|
||||||
if (!pb)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = (parse_multipart_header(pb, &size, "--", NULL) >= 0) ? AVPROBE_SCORE_MAX : 0;
|
ret = (parse_multipart_header(&pb, &size, "--", NULL) >= 0) ? AVPROBE_SCORE_MAX : 0;
|
||||||
|
|
||||||
avio_context_free(&pb);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user