summaryrefslogtreecommitdiff
path: root/libavformat/pcmdec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-02-10 07:41:21 +0100
committerAnton Khirnov <anton@khirnov.net>2014-02-10 07:41:21 +0100
commit38893dc028e458eaf3f906833d4ee515689edb7e (patch)
treed741c42ce475d965abd15f93e10ebb6d41c40935 /libavformat/pcmdec.c
parentcca4742a5e663cfe4dbd71f01f0c0fb042fddc1d (diff)
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.
Diffstat (limited to 'libavformat/pcmdec.c')
-rw-r--r--libavformat/pcmdec.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c
index 716d8b7977..1bbbc66d17 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);