This is why C code is bad, because C programmers never ask themselves, "How do I not leak memory?"
Another way to phrase that would be, "This is why C code is bad, because C programmers are expected to understand the rules about how to not leak memory, but there is no mechanism to enforce that requirement".
... and to their credit, eventually some of them do figure it out, and after that they (mostly) write good C code that doesn't leak. However, that doesn't change the fact that at any given moment there are millions of unseasoned C programmers out there who haven't reached that point yet, and who are nevertheless writing leaky code which gets put into production and causes trouble; and new C programmers appear every day. It's the Eternal September problem, applied to memory management.
So either (a) we ban C programmers from pushing to production until they've had at least 5 years of experience, or (b) we find some means to flag their errors at build-time, or (c) we live with the status quo messiness indefinitely. Linux is going with Rust as their mechanism for implementing plan (b).