1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/mlvdec: process ff_get_wav_header return value

Fixes CID1206640.

Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Peter Ross 2014-04-27 12:42:04 +10:00 committed by Michael Niedermayer
parent c9cfd45838
commit bdab0c2d76

View File

@ -123,10 +123,11 @@ static void read_uint64(AVFormatContext *avctx, AVIOContext *pb, const char *tag
av_dict_set(&avctx->metadata, tag, value, 0); av_dict_set(&avctx->metadata, tag, value, 0);
} }
static void scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int file) static int scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int file)
{ {
MlvContext *mlv = avctx->priv_data; MlvContext *mlv = avctx->priv_data;
AVIOContext *pb = mlv->pb[file]; AVIOContext *pb = mlv->pb[file];
int ret;
while (!url_feof(pb)) { while (!url_feof(pb)) {
int type; int type;
unsigned int size; unsigned int size;
@ -151,7 +152,9 @@ static void scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int
vst->codec->codec_tag = MKTAG('B', 'I', 'T', 16); vst->codec->codec_tag = MKTAG('B', 'I', 'T', 16);
size -= 164; size -= 164;
} else if (ast && type == MKTAG('W', 'A', 'V', 'I') && size >= 16) { } else if (ast && type == MKTAG('W', 'A', 'V', 'I') && size >= 16) {
ff_get_wav_header(pb, ast->codec, 16); ret = ff_get_wav_header(pb, ast->codec, 16);
if (ret < 0)
return ret;
size -= 16; size -= 16;
} else if (type == MKTAG('I','N','F','O')) { } else if (type == MKTAG('I','N','F','O')) {
if (size > 0) if (size > 0)
@ -240,6 +243,7 @@ static void scan_file(AVFormatContext *avctx, AVStream *vst, AVStream *ast, int
} }
avio_skip(pb, size); avio_skip(pb, size);
} }
return 0;
} }
static int read_header(AVFormatContext *avctx) static int read_header(AVFormatContext *avctx)
@ -247,7 +251,7 @@ static int read_header(AVFormatContext *avctx)
MlvContext *mlv = avctx->priv_data; MlvContext *mlv = avctx->priv_data;
AVIOContext *pb = avctx->pb; AVIOContext *pb = avctx->pb;
AVStream *vst = NULL, *ast = NULL; AVStream *vst = NULL, *ast = NULL;
int size; int size, ret;
uint64_t guid; uint64_t guid;
char guidstr[32]; char guidstr[32];
@ -332,7 +336,9 @@ static int read_header(AVFormatContext *avctx)
/* scan primary file */ /* scan primary file */
mlv->pb[100] = avctx->pb; mlv->pb[100] = avctx->pb;
scan_file(avctx, vst, ast, 100); ret = scan_file(avctx, vst, ast, 100);
if (ret < 0)
return ret;
/* scan secondary files */ /* scan secondary files */
if (strlen(avctx->filename) > 2) { if (strlen(avctx->filename) > 2) {
@ -351,7 +357,13 @@ static int read_header(AVFormatContext *avctx)
continue; continue;
} }
av_log(avctx, AV_LOG_INFO, "scanning %s\n", filename); av_log(avctx, AV_LOG_INFO, "scanning %s\n", filename);
scan_file(avctx, vst, ast, i); ret = scan_file(avctx, vst, ast, i);
if (ret < 0) {
av_log(avctx, AV_LOG_WARNING, "ignoring %s; %s\n", filename, av_err2str(ret));
avio_close(mlv->pb[i]);
mlv->pb[i] = NULL;
continue;
}
} }
av_free(filename); av_free(filename);
} }