7 ms·
In our codebase though we have some places where we do `delete this;` and later use placement new, to restore `this` to some valid state.
by enedil 5y ago
In our codebase though we have some places where we do `delete this;` and later use placement new, to restore `this` to some valid state.
- Rusky 5y agoThat only seems tangentially related to me, but it is interesting, haha. Specifically that sounds like it would cause use-after-frees- if you actually `delete this` and then `new (this) Bla`, you're writing to memory that's already been returned to the allocator. Maybe you meant `this->~Bla()` rather than `delete this`? Or a custom `operator delete`?