Vagrind would have been an option, but he stated he's using the Visual Studio and afaik valgrind does unfortunately not work in windows.
I normally use valgrind to check for things like this. It walks through your program and gives dynamic warnings on uninitialized variables and also memory leaks
However, I just remembered that starting with VS2012 the static code analysis is included in all versions starting with professional (it used to be limited to higher versions before). That should have caught it as well. Additionally, they finally made the profiler and the concurrency visualizer available for VS professional as well.