This was added because UBSan was warning that we were calling memcpy with a null destination, and while that is technically true, it was also a no-op because it was copying 0 bytes. A null buffer gets properly resized with the data in the next step, so this is actually expected behaviour that is broken by asserting too early.
Instead, detect the cases where we're calling memcpy with actual data, and assert in those cases that the RAMStream buffer is non-null.
This was added because UBSan was warning that we were calling memcpy with a null destination, and while that is technically true, it was also a no-op because it was copying 0 bytes. A null buffer gets properly resized with the data in the next step, so this is actually expected behaviour that is broken by asserting too early.
Instead, detect the cases where we're calling memcpy with actual data, and assert in those cases that the RAMStream buffer is non-null.