When using SDL_Surface
s to handle images, I run into the problem that running SDL_FreeSurface(SDL_Surface *)
(doc) twice on the same pointer yields a segmentation fault.
I understand why that happens, but I need to know how I can avoid that. I'd like to check the state of the pointer (find out if its pointing to an existing surface) and then Free the surface only if necessary.
How can I do that?