[FFmpeg-cvslog] pcmdec: replace a reachable assert with an error check

Anton Khirnov git at videolan.org
Mon Feb 10 12:39:16 CET 2014


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Feb 10 07:41:21 2014 +0100| [38893dc028e458eaf3f906833d4ee515689edb7e] | committer: Anton Khirnov

pcmdec: replace a reachable assert with an error check

Libavformat should not make any assumptions about values returned from
other libraries. This assert is easily reachable by using a non-raw
codec id.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=38893dc028e458eaf3f906833d4ee515689edb7e
---

 libavformat/pcmdec.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index 716d8b7..1bbbc66 100644
--- a/libavformat/pcmdec.c
+++ b/libavformat/pcmdec.c
@@ -74,7 +74,11 @@ static int pcm_read_packet(AVFormatContext *s, AVPacket *pkt)
         return ret;
 
     bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
-    assert(bps); // if false there IS a bug elsewhere (NOT in this function)
+    if (!bps) {
+        av_log(s, AV_LOG_ERROR, "Unknown number of bytes per sample.\n");
+        return AVERROR(EINVAL);
+    }
+
     pkt->dts=
     pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels);
 



More information about the ffmpeg-cvslog mailing list