Valgrind is a great tool, but I don’t think it’s available on Windows. “Sanitizers”, that come with many modern compilers nowadays, provide similar functionality.
I noticed that a similar issue got fixed in the SDL codebase just a few hours ago so you are apparently not alone in making this sort of mistake.