Freeing surface sometimes is causing segmentation fault

I’ve posted it before and now tested it again. I still getting segment fault sometimes when I try to free a SDL_Surface (which is checked if isn’t NULL, and when freed is set to NULL). This only happens in the debug mode. I run it 2~5 times and it gives me the error, but when I try to run it again, it runs with no problems whatsoever.