There’s a problem when writing streams greater than 32-bit to a juce::MemoryBlock.
The problem is here:
if (storageNeeded >= blockToUse->getSize())
blockToUse->ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & ~31u);
That last ~31u is a 32-bit unsigned int so will wrap values around to that range.
The cleanest solution would be to use the uz suffix but I think just static_casting it to size_t should also work?
Here’s a godbolt showing the problem and the fix: Compiler Explorer
