mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 497815 - Read Wave headers in small chunks to avoid unnecessary large allocations. r=roc
--HG-- extra : rebase_source : 355af524b6d9f0634d9d09e4ddc1ce1715bc6c81
This commit is contained in:
parent
6174ee7312
commit
658839d732
@ -976,19 +976,23 @@ nsWaveStateMachine::ScanForwardUntil(PRUint32 aWantedChunk, PRUint32* aChunkSize
|
||||
}
|
||||
|
||||
PRUint32 magic = ReadUint32BE(&p);
|
||||
PRUint32 size = ReadUint32LE(&p);
|
||||
PRUint32 chunkSize = ReadUint32LE(&p);
|
||||
|
||||
if (magic == aWantedChunk) {
|
||||
*aChunkSize = size;
|
||||
*aChunkSize = chunkSize;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// RIFF chunks are two-byte aligned, so round up if necessary.
|
||||
size += size % 2;
|
||||
chunkSize += chunkSize % 2;
|
||||
|
||||
nsAutoArrayPtr<char> chunk(new char[size]);
|
||||
if (!ReadAll(chunk.get(), size)) {
|
||||
return PR_FALSE;
|
||||
while (chunkSize > 0) {
|
||||
PRUint32 size = PR_MIN(chunkSize, 1 << 16);
|
||||
nsAutoArrayPtr<char> chunk(new char[size]);
|
||||
if (!ReadAll(chunk.get(), size)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
chunkSize -= size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user