MemoryBlock::copyFrom not copying all the data (not corruption)

Unlike e.g.LoadFromHexString, MemoryBlock::copyFrom does not ensure the size of the MemoryBlock before doing a memcpy.

If there’s a good reason why it doesn’t can the doc at least make that really clear and jassert?
Thanks :slight_smile:

If you want a full copy, you can simply use the = operator.

The docs do make it clear that this case is handled:
https://docs.juce.com/master/classMemoryBlock.html#a31d3f1d7a0269229c5f0c36ab0b9dc40
numBytes how much to copy in (if this goes beyond the size of the memory block, it will be clipped so not to do anything nasty)

1 Like

Ahh, so it does, Thanks.
Home schooling and reading docs properly is not quite going as well as I thought :smiley:

Obviously the kids need to be reading the docs!

1 Like