Code scanning alert #487 "Multiplication result converted to larger type"

My own fix, not auto-generated.
m_iChannels is implicitly promoted to size_t.
This commit is contained in:
sukibaby
2025-05-06 06:12:55 -07:00
committed by teejusb
parent 21e6498414
commit 33a6912778
+4 -1
View File
@@ -341,11 +341,14 @@ int RageSoundReader_Chain::Read( float *pBuffer, int iFrames )
return iFrames;
}
// Note: this is only safe because we know pBuffer is not nullptr
// and iFrames and m_iChannels are reasonable sizes.
if( m_apActiveSounds.empty() )
{
/* If we have more sounds ahead of us, pretend we read the entire block, since
* there's silence in between. Otherwise, we're at EOF. */
memset( pBuffer, 0, iFrames * m_iChannels * sizeof(float) );
size_t pBufferSize = static_cast<size_t>(iFrames) * m_iChannels * sizeof(float);
memset( pBuffer, 0, pBufferSize );
m_iCurrentFrame += iFrames;
return iFrames;
}