buffer is a pointer, so it doesn't have a destructor.  If it was an owned pointer you might need to say tgt = buffer.getClear() or something.