3 ms·
For all it's many faults, even C++ fstreams is not vulnerable to double freeing (and as a partial reply to @Galanwe, they way they avoid issues is runtime check
by im3w1l 2y ago
For all it's many faults, even C++ fstreams is not vulnerable to double freeing (and as a partial reply to @Galanwe, they way they avoid issues is runtime checking).
- kllrnohj 2y agoIn C++ you can also make the FD-equivalent of std::unique_ptr, like Android does with unique_fd: https://cs.android.com/android/platform/superproject/main/+/main:system/libbase/include/android-base/unique_fd.h https://cs.android.com/android/platform/superproject/main/+/... It doesn't guarantee the issue never happens, like Rust would, but it does make it dramatically less likely to occur. Also I think in general people vastly under-appreciate how severe an issue EBADF actually is. Outside of extremely specific, single-thread-only scenarios, that error is essentially the kernel telling you that heap corruption occurred, but almost nobody treats it with that level of severity
- pjmlp 2y agoAlready in early 1990s, with C++ARM as the first standard, there were plenty of advantages using C++ instead of plain C. RAII, streams instead of stdio patters, compilers had collection classes for common types (string, array, ...) with bounds checking configuration,....