mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 01:04:02 +02:00
Try fixing an infinite loop.
This commit is contained in:
+9
-4
@@ -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
|
|||||||
*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
|
|||||||
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
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user