Check data sizes properly

master
Marc Gilleron 2020-01-26 01:33:45 +00:00
parent 4b52d8fd18
commit f530daaf03
1 changed files with 3 additions and 1 deletions

View File

@ -478,7 +478,9 @@ void VoxelBuffer::copy_from(const VoxelBuffer &other, unsigned int channel_index
if (channel.data == NULL) { if (channel.data == NULL) {
create_channel_noinit(channel_index, _size); create_channel_noinit(channel_index, _size);
} }
memcpy(channel.data, other_channel.data, get_volume() * sizeof(uint8_t)); CRASH_COND(channel.size_in_bytes != other_channel.size_in_bytes);
memcpy(channel.data, other_channel.data, channel.size_in_bytes);
} else if (channel.data) { } else if (channel.data) {
delete_channel(channel_index); delete_channel(channel_index);
} }