Strange segfault from SDL_FreeSurface
I have the following simple SDL code: #include <SDL.h> #include <stdbool.h> #include <stdio.h> // helpers bool init(SDL_Window **win, SDL_Surface **surf) { int const width = 800; int const height = 600; if (SDL_Init(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); return false; } *win = SDL_CreateWindow("Picture test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0); if (*win == NULL) { fprintf(stderr, "Unable to create window: %s\n", SDL_GetError()); return false; } *surf = SDL_GetWindowSurface(*win); return true; } bool load_media(SDL