| 1 | From: Antonio Larrosa <[email protected]>
|
| 2 | Date: Thu, 9 Mar 2017 10:21:18 +0100
|
| 3 | Subject: Check for division by zero in BlockCodec::runPull
|
| 4 |
|
| 5 | ---
|
| 6 | libaudiofile/modules/BlockCodec.cpp | 2 +-
|
| 7 | 1 file changed, 1 insertion(+), 1 deletion(-)
|
| 8 |
|
| 9 | diff --git a/libaudiofile/modules/BlockCodec.cpp b/libaudiofile/modules/BlockCodec.cpp
|
| 10 | index 4731be1..eb2fb4d 100644
|
| 11 | |
| 12 | |
| 13 | @@ -47,7 +47,7 @@ void BlockCodec::runPull()
|
| 14 |
|
| 15 | // Read the compressed data.
|
| 16 | ssize_t bytesRead = read(m_inChunk->buffer, m_bytesPerPacket * blockCount);
|
| 17 | - int blocksRead = bytesRead >= 0 ? bytesRead / m_bytesPerPacket : 0;
|
| 18 | + int blocksRead = (bytesRead >= 0 && m_bytesPerPacket > 0) ? bytesRead / m_bytesPerPacket : 0;
|
| 19 |
|
| 20 | // Decompress into m_outChunk.
|
| 21 | for (int i=0; i<blocksRead; i++)
|