Without reading the code for BKE_mesh_copy I also got a bit tripped up that you had to do id_free instead of mesh_free.
Perhaps the additional variable bmain in the copy call could be enough of a hint that it is simply not just copying that data for the mesh... (But to me it was still unclear if I just go by what the actual function is called)
This patch seems fine to me, but I feel that perhaps we could make it more clear that mesh_copy doesn't actually just copy the mesh?
@Brecht Van Lommel (brecht) ^
Thought that would most likely not be something we should slap into this patch.