mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
avformat/icodec: Simplify cleanup after read_header failure
by setting the FF_FMT_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
0a7e911108
commit
7a1037b6bd
@ -96,13 +96,11 @@ static int read_header(AVFormatContext *s)
|
||||
int tmp;
|
||||
|
||||
if (avio_seek(pb, 6 + i * 16, SEEK_SET) < 0)
|
||||
goto fail;
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
st = avformat_new_stream(s, NULL);
|
||||
if (!st) {
|
||||
av_freep(&ico->images);
|
||||
if (!st)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
st->codecpar->width = avio_r8(pb);
|
||||
@ -116,12 +114,12 @@ static int read_header(AVFormatContext *s)
|
||||
ico->images[i].size = avio_rl32(pb);
|
||||
if (ico->images[i].size <= 0) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid image size %d\n", ico->images[i].size);
|
||||
goto fail;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
ico->images[i].offset = avio_rl32(pb);
|
||||
|
||||
if (avio_seek(pb, ico->images[i].offset, SEEK_SET) < 0)
|
||||
goto fail;
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
||||
codec = avio_rl32(pb);
|
||||
switch (codec) {
|
||||
@ -131,9 +129,8 @@ static int read_header(AVFormatContext *s)
|
||||
st->codecpar->height = 0;
|
||||
break;
|
||||
case 40:
|
||||
if (ico->images[i].size < 40) {
|
||||
goto fail;
|
||||
}
|
||||
if (ico->images[i].size < 40)
|
||||
return AVERROR_INVALIDDATA;
|
||||
st->codecpar->codec_id = AV_CODEC_ID_BMP;
|
||||
tmp = avio_rl32(pb);
|
||||
if (tmp)
|
||||
@ -144,14 +141,11 @@ static int read_header(AVFormatContext *s)
|
||||
break;
|
||||
default:
|
||||
avpriv_request_sample(s, "codec %d", codec);
|
||||
goto fail;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
av_freep(&ico->images);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
@ -224,6 +218,7 @@ const AVInputFormat ff_ico_demuxer = {
|
||||
.name = "ico",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Microsoft Windows ICO"),
|
||||
.priv_data_size = sizeof(IcoDemuxContext),
|
||||
.flags_internal = FF_FMT_INIT_CLEANUP,
|
||||
.read_probe = probe,
|
||||
.read_header = read_header,
|
||||
.read_packet = read_packet,
|
||||
|
Loading…
Reference in New Issue
Block a user