There is no easy fix for this, because the simple fact is that software systems are often inherently complex, and usually developed on crunched schedules. However, the right programming language can be rather helpful in improving software quality.
First of all, nobody should be using C and C++ to write typical applications anymore. When I say "typical,", I mean apps which are not performance-critical, hard real-time, or very close to the hardware level. For operating systems, device drivers, hard real-time industrial controllers, and the like, C/C++ is the way to go. For everything else, use a garbage-collected language. Then there will be no more memory leaks.
Secondly, use a strongly and statically-typed object-oriented language. I don't have time to produce a lengthy discussion of why now, but trust me, it helps you catch bugs earlier in the development process (like, at compile time). It also greatly improves the ability to manage the complexity of complex software systems by enhancing modularity and facilitating reuse.
Lastly, build quality-control mechanisms into the code. That means checking parameter validity using assertions, including robust exception-handling, and designing code to facilitate testing and debugging. (Each module/class should be testable in isolation, or near isolation.)
As far as I know, the only widely-used language that satisfies all of these requirements is Eiffel. Java comes close, but lacks strong typing (because of the lack of genericity, aka templates) and does not include an assertion mechanism. (You can roll your own assertions, but then they impact run-time performance. You need to be able to turn off assertion checking when you put the code in production.)
Eiffel is cool. Go to the website, read about it, code in it. 'Nuff said.