I think you prevent these "corrupt file corrupts important memory" bugs in two ways: 1) use a memory safe language 2) write fuzz tests just like you'd write unit tests.
1 is becoming extremely viable, infrastructure for 2 is starting to be included with modern programming languages and so will soon become the norm.
1 is becoming extremely viable, infrastructure for 2 is starting to be included with modern programming languages and so will soon become the norm.