3 ms·
No experienced C programmer will write this code, but years of buffer overflow/double free CVEs show that even experienced programmers make such errors occasion
by danieldk 9y ago
No experienced C programmer will write this code, but years of buffer overflow/double free CVEs show that even experienced programmers make such errors occasionally. And one error can be enough for a system compromise.
Of course, this is not only an argument in favor of in Rust, but any memory-safe language. Rust just happens to address some of the same problem domains that C and C++ have traditionally been dominant in.
- viperscape 9y agoWhy is double free so commonly an issue? Isn't setting to Null after free and checking for Null before hand a common practice?
- sidlls 9y agoIt isn't that common. On HN, however, you'd think there isn't a piece of software written in C that isn't responsible for mayhem and death. The sort of FUD around the language, driven helpfully by the Rust Evangelism Strikeforce, isn't helpful.
- tene 9y agoIt's usually not calling free() on the same variable within a single function, although that can sometimes happen. The most common case, I expect, is when two separate data structures both have pointers to the same object and believe they own it, then later end up calling free on the same address at different times.