I wrote a small Buffer class: the constructor does data = new uint8_t[size]; and the destructor does delete[] data;. It works until I pass a Buffer to a function by value or store one in a std::vector. Then the program crashes on exit with a double free, or the contents of one buffer change when I write to another.
I never wrote any copying code, so what is being copied, and what do I need to add to make the class safe?




