[FFmpeg-devel] [PATCH] rawdec: add check on sample_rate

Michael Niedermayer michaelni at gmx.at
Thu Oct 27 03:24:09 CEST 2011


On Thu, Oct 27, 2011 at 01:42:30AM +0200, Stefano Sabatini wrote:
> Prevent error condition in case sample_rate is unset or set to a negative
> value. In particular, fix divide-by-zero error occurring in ffmpeg due to
> sample_rate set to 0 in output_packet(), in code:
> 
>                 ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
>                     ist->st->codec->sample_rate;
> 
> Fix trac ticket #324.
> ---
>  libavformat/rawdec.c |   11 ++++++++++-
>  1 files changed, 10 insertions(+), 1 deletions(-)
> 
> diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
> index 37e9b0c..f65266b 100644
> --- a/libavformat/rawdec.c
> +++ b/libavformat/rawdec.c
> @@ -46,6 +46,8 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
>          st->codec->codec_id = id;
>  
>          switch(st->codec->codec_type) {
> +            int ret = 0;
> +

undefined behavior i suspect.

otherwise LGTM


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111027/54fb1529/attachment.asc>


More information about the ffmpeg-devel mailing list