[Ffmpeg-devel] [PATCH] minor fixes for invalid audio data
Wolfram Gloger
wmglo
Sun Aug 14 16:32:48 CEST 2005
Here are two very minor fixes which I discovered while inadvertently
feeding more or less random data to some audio decoders.. They
prevent ffmpeg from seg'faulting on invalid input data.
Regards,
Wolfram.
diff -ur ffmpeg/libavcodec/resample2.c ffmpeg-wg/libavcodec/resample2.c
--- ffmpeg/libavcodec/resample2.c Tue Jan 18 19:37:13 2005
+++ ffmpeg-wg/libavcodec/resample2.c Sun Aug 14 14:00:25 2005
@@ -139,7 +139,7 @@
c->phase_mask= phase_count-1;
c->linear= linear;
- c->filter_length= FFMAX(ceil(filter_size/factor), 1);
+ c->filter_length= FFMAX((int)ceil(filter_size/factor), 1);
c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM));
av_build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, 1);
memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM));
diff -ur ffmpeg/libavformat/utils.c ffmpeg-wg/libavformat/utils.c
--- ffmpeg/libavformat/utils.c Mon Jul 18 10:52:35 2005
+++ ffmpeg-wg/libavformat/utils.c Sun Aug 14 14:36:04 2005
@@ -2164,20 +2264,24 @@
/* init PTS generation */
for(i=0;i<s->nb_streams;i++) {
+ int64_t den = AV_NOPTS_VALUE;
st = s->streams[i];
switch (st->codec->codec_type) {
case CODEC_TYPE_AUDIO:
- av_frac_init(&st->pts, 0, 0,
- (int64_t)st->time_base.num * st->codec->sample_rate);
+ den = (int64_t)st->time_base.num * st->codec->sample_rate;
break;
case CODEC_TYPE_VIDEO:
- av_frac_init(&st->pts, 0, 0,
- (int64_t)st->time_base.num * st->codec->time_base.den);
+ den = (int64_t)st->time_base.num * st->codec->time_base.den;
break;
default:
break;
}
+ if (den != AV_NOPTS_VALUE) {
+ if (den <= 0)
+ return AVERROR_INVALIDDATA;
+ av_frac_init(&st->pts, 0, 0, den);
+ }
}
return 0;
}
More information about the ffmpeg-devel
mailing list