Convert tail-recursion to loop to avoid stack exhaustion.

This commit is contained in:
Kevin Backhouse 2023-03-11 23:17:49 +00:00 committed by Rosen Penev
parent a783320520
commit 244799f480

View File

@ -456,17 +456,14 @@ void RiffVideo::readChunk(HeaderReader& header_) {
} }
void RiffVideo::decodeBlocks() { void RiffVideo::decodeBlocks() {
do {
HeaderReader header(io_); HeaderReader header(io_);
if (equal(header.getId(), CHUNK_ID_LIST)) { if (equal(header.getId(), CHUNK_ID_LIST)) {
readList(header); readList(header);
} else { } else {
readChunk(header); readChunk(header);
} }
} while (!io_->eof() && io_->tell() < io_->size());
if (!io_->eof() && io_->tell() < io_->size()) {
decodeBlocks();
}
} // RiffVideo::decodeBlock } // RiffVideo::decodeBlock
void RiffVideo::readAviHeader() { void RiffVideo::readAviHeader() {