X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Ftta.c;h=6e513563bed11a69c90fdf0805ef5050d7c1eea5;hb=01fcbdf9cedcf14418b5886205261e532167f949;hp=23e54b2fda43b8c10a0723e0e1ddbe06e3e2e5fb;hpb=9b471735459d7274f6d7cc646f1d01011f844862;p=ffmpeg diff --git a/libavformat/tta.c b/libavformat/tta.c index 23e54b2fda4..6e513563bed 100644 --- a/libavformat/tta.c +++ b/libavformat/tta.c @@ -21,6 +21,7 @@ #include "libavcodec/get_bits.h" #include "avformat.h" +#include "internal.h" #include "id3v1.h" #include "libavutil/dict.h" @@ -72,16 +73,16 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap) c->totalframes = datalen / framelen + ((datalen % framelen) ? 1 : 0); c->currentframe = 0; - if(c->totalframes >= UINT_MAX/sizeof(uint32_t)){ - av_log(s, AV_LOG_ERROR, "totalframes too large\n"); + if(c->totalframes >= UINT_MAX/sizeof(uint32_t) || c->totalframes <= 0){ + av_log(s, AV_LOG_ERROR, "totalframes %d invalid\n", c->totalframes); return -1; } - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); - av_set_pts_info(st, 64, 1, samplerate); + avpriv_set_pts_info(st, 64, 1, samplerate); st->start_time = 0; st->duration = datalen; @@ -107,6 +108,10 @@ static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap) return -1; } st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE); + if (!st->codec->extradata) { + st->codec->extradata_size = 0; + return AVERROR(ENOMEM); + } avio_seek(s->pb, start_offset, SEEK_SET); avio_read(s->pb, st->codec->extradata, st->codec->extradata_size); @@ -120,8 +125,8 @@ static int tta_read_packet(AVFormatContext *s, AVPacket *pkt) int size, ret; // FIXME! - if (c->currentframe > c->totalframes) - return -1; + if (c->currentframe >= c->totalframes) + return AVERROR_EOF; size = st->index_entries[c->currentframe].size;