Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
AudioOutputBase: Fix Coverity 746803. Division by zero
  • Loading branch information
stuartm committed Jun 9, 2013
1 parent 47e3a59 commit d75264e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mythtv/libs/libmyth/audio/audiooutputbase.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit d75264e

Please sign in to comment.