Permalink
Browse files

AudioOutputBase: Fix Coverity 746803. Division by zero

  • Loading branch information...
stuartm committed Jun 9, 2013
1 parent 47e3a59 commit d75264e44013b274f454946673ae23f2964cb831
Showing with 9 additions and 2 deletions.
  1. +9 −2 mythtv/libs/libmyth/audio/audiooutputbase.cpp
@@ -1400,9 +1400,16 @@ bool AudioOutputBase::AddData(void *in_buffer, int in_len,
// Calculate amount of free space required in ringbuffer
if (processing)
{
int sampleSize = AudioOutputSettings::SampleSize(format);
if (sampleSize <= 0)
{
// Would lead to division by zero (or unexpected results if negative)
VBERROR("Sample size is <= 0, AddData returning false");
return false;
}
// Final float conversion space requirement
len = sizeof(*src_in_buf) /
AudioOutputSettings::SampleSize(format) * len;
len = sizeof(*src_in_buf) / sampleSize * len;
// Account for changes in number of channels
if (needs_downmix)

0 comments on commit d75264e

Please sign in to comment.