memoryBlock.getData() return invalid data

Hi, I have really strange scenario that I don’t know how to solve and I don’t understand, this is my code:

//MARK: debug
DBG(memoryBlock.toBase64Encoding()); // this print 
void* data = memoryBlock.getData();
int size = memoryBlock.getSize();
std::unique_ptr<XmlElement> xmlElement = AudioProcessor::getXmlFromBinary(data, size); // crash
DBG(xmlElement->toString());
//MARK: /debug

this code crashes at line std::unique_ptr xmlElement = AudioProcessor::getXmlFromBinary(data, size); raising:

JUCE Message Thread (1): EXC_BAD_ACCESS (code=1, address=0x18)

at line *bool isEmpty() const noexcept { return data == 0; } of module juce_CharPointer_UTF8 (data is NULL).

I suppose if data was invalid I shouldn’t have been able to print in line DBG(memoryBlock.toBase64Encoding()); right? so where’s the problem here?

I obtain memoryBlock from a file saved before in this way:

juce::MemoryBlock destData;
std::unique_ptr<XmlElement> xml { createPresetXml(elems) };
DBG(xml->toString()); //this print in the right things
copyXmlToBinary(*xml.get(), destData);
return destData;