Commit 1c179fb4 authored by David Reid's avatar David Reid

Try fixing an infinite loop.

parent 38f2754e
...@@ -46498,8 +46498,9 @@ static ma_result ma_decoder_read_bytes(ma_decoder* pDecoder, void* pBufferOut, s ...@@ -46498,8 +46498,9 @@ static ma_result ma_decoder_read_bytes(ma_decoder* pDecoder, void* pBufferOut, s
{ {
size_t bytesRead; size_t bytesRead;
MA_ASSERT(pDecoder != NULL); MA_ASSERT(pDecoder != NULL);
MA_ASSERT(pBufferOut != NULL); MA_ASSERT(pBufferOut != NULL);
MA_ASSERT(bytesToRead > 0); /* It's an error to call this with a byte count of zero. */
bytesRead = pDecoder->onRead(pDecoder, pBufferOut, bytesToRead); bytesRead = pDecoder->onRead(pDecoder, pBufferOut, bytesToRead);
...@@ -46507,6 +46508,10 @@ static ma_result ma_decoder_read_bytes(ma_decoder* pDecoder, void* pBufferOut, s ...@@ -46507,6 +46508,10 @@ static ma_result ma_decoder_read_bytes(ma_decoder* pDecoder, void* pBufferOut, s
*pBytesRead = bytesRead; *pBytesRead = bytesRead;
} }
if (bytesRead == 0) {
return MA_AT_END;
}
return MA_SUCCESS; return MA_SUCCESS;
} }
...@@ -47247,7 +47252,7 @@ static ma_uint64 ma_vorbis_decoder_read_pcm_frames(ma_vorbis_decoder* pVorbis, m ...@@ -47247,7 +47252,7 @@ static ma_uint64 ma_vorbis_decoder_read_pcm_frames(ma_vorbis_decoder* pVorbis, m
pVorbis->dataSize += bytesRead; pVorbis->dataSize += bytesRead;
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return totalFramesRead; /* Error reading more data. */ return totalFramesRead; /* Error reading more data, or end of file. */
} }
} }
} while (MA_TRUE); } while (MA_TRUE);
...@@ -47378,7 +47383,7 @@ static ma_result ma_decoder_init_vorbis__internal(const ma_decoder_config* pConf ...@@ -47378,7 +47383,7 @@ static ma_result ma_decoder_init_vorbis__internal(const ma_decoder_config* pConf
result = ma_decoder_read_bytes(pDecoder, pData + dataSize, (dataCapacity - dataSize), &bytesRead); result = ma_decoder_read_bytes(pDecoder, pData + dataSize, (dataCapacity - dataSize), &bytesRead);
dataSize += bytesRead; dataSize += bytesRead;
if (result != MA_SUCCESS) { if (result != MA_SUCCESS && (result != MA_AT_END || bytesRead == 0)) {
return result; return result;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment