mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
xmv: check audio track parameters validity.
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org
This commit is contained in:
parent
b88f902125
commit
d1016dccdc
@ -126,6 +126,16 @@ static int xmv_probe(AVProbeData *p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmv_read_close(AVFormatContext *s)
|
||||
{
|
||||
XMVDemuxContext *xmv = s->priv_data;
|
||||
|
||||
av_free(xmv->audio);
|
||||
av_free(xmv->audio_tracks);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmv_read_header(AVFormatContext *s)
|
||||
{
|
||||
XMVDemuxContext *xmv = s->priv_data;
|
||||
@ -135,6 +145,7 @@ static int xmv_read_header(AVFormatContext *s)
|
||||
uint32_t file_version;
|
||||
uint32_t this_packet_size;
|
||||
uint16_t audio_track;
|
||||
int ret;
|
||||
|
||||
avio_skip(pb, 4); /* Next packet size */
|
||||
|
||||
@ -211,6 +222,13 @@ static int xmv_read_header(AVFormatContext *s)
|
||||
av_log(s, AV_LOG_WARNING, "Unsupported 5.1 ADPCM audio stream "
|
||||
"(0x%04X)\n", track->flags);
|
||||
|
||||
if (!track->channels || !track->sample_rate) {
|
||||
av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %d.\n",
|
||||
audio_track);
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ast = avformat_new_stream(s, NULL);
|
||||
if (!ast)
|
||||
return AVERROR(ENOMEM);
|
||||
@ -239,6 +257,10 @@ static int xmv_read_header(AVFormatContext *s)
|
||||
xmv->stream_count = xmv->audio_track_count + 1;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
xmv_read_close(s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void xmv_read_extradata(uint8_t *extradata, AVIOContext *pb)
|
||||
@ -546,16 +568,6 @@ static int xmv_read_packet(AVFormatContext *s,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xmv_read_close(AVFormatContext *s)
|
||||
{
|
||||
XMVDemuxContext *xmv = s->priv_data;
|
||||
|
||||
av_free(xmv->audio);
|
||||
av_free(xmv->audio_tracks);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVInputFormat ff_xmv_demuxer = {
|
||||
.name = "xmv",
|
||||
.long_name = NULL_IF_CONFIG_SMALL("Microsoft XMV"),
|
||||
|
Loading…
Reference in New Issue
Block a user