3 ms·
foo() might throw an exception, leaking "p". Stack allocation should probably be used instead of heap allocation here, anyway.
by neilc 17y ago
foo() might throw an exception, leaking "p". Stack allocation should probably be used instead of heap allocation here, anyway.
- brl 17y agoThanks for reminding me why I'm never going anywhere near C++ ever again in my life. Good answer though, I was stumped.
- lacker 17y agoUgh. Good point though. Reminds me of why my company forbids the use of exceptions in C++ programming.
- aminuit 17y agoI totally missed it too. People are using this to bash C++ which is probably fair, but it's worth noting that lots of modern C++ folks default to using RAII pointer types (std::auto_ptr, boost::shared_ptr) to guard against these types of errors.