I think MemoryBlock should have both allocated size and used size attributes.
MemoryBlock block(4096); InputStream* stream = url.createInputStream (...); stream->readIntoMemoryBlock (block, 4096);
This will read into memory block past the initial 4096 bytes, and it obviously misses the logic behind the above code.
See InputStream::readIntoMemoryBlock() method which appends data to MemoryBlock passed to MemoryOutputStream.
At least it should be noted in the documentation about this feature of MemoryBlock.