3 ms·
unique_ptr isn't safe, and it doesn't provide any safety that you didn't have with smart pointers in earlier versions of C++. In fact, I'm even skeptical of th
by pcwalton 11y ago
unique_ptr isn't safe, and it doesn't provide any safety that you didn't have with smart pointers in earlier versions of C++.
In fact, I'm even skeptical of the claim that unique_ptr provides significant security benefits over malloc and free. Leaks aren't the kinds of security problems we're talking about here.
- telos 11y agoThis isn't true - unique_ptr provides protection against Use after Free which is one of the most common memory corruption vulnerabilities in modern applications.
- pcwalton 11y agoNo, it doesn't. There are many ways to get use after free using unique_ptr combined with references or this pointers.
- RotsiserMho 11y agoProtection != prevention
- pcwalton 11y agoI don't know what this means, but if you're implying that unique_ptr is good enough to prevent use after free in practice, that is obviously empirically false. Every browser engine, for example, uses C++11 and regularly has exploitable use after free.