I declared the vector:
for(int i = 0; i < my_vect.size(); i++)
for(int i = 0; i < new_my_vect.size(); i++)
free(): invalid pointer:
You should be adding objects as follows
vector<Object> my_vect; my_vect.emplace_back();
I would not recommend getting pointers to the objects within the vector, as if anything causes the vector to re-allocate those pointers will be invalidated as the underlying array will be copied elsewhere.