mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-07-27 17:41:49 +03:00
6810c5fa8c
When `SDL_RenderReadPixels` fails for some reason, the game tries to free the temporary source surface it creates. Unfortunately, it never sets it to `NULL` after, so the next time the game tries to render the filter, it'll try to work with a memory region that was already freed. To fix this, I just replaced `SDL_FreeSurface(*src);` with `VVV_freefunc(SDL_FreeSurface, *src);` which is a helper macro which sets the pointer to NULL after freeing. Now, there's a new issue -- since the temporary buffer is now NULL, next frame we'll try to remake it! So I've introduced a static bool which disables the filter entirely if `SDL_RenderReadPixels` fails. Without this, it'd create and destroy a surface every frame, which could lead to slowdown. (Not as slow as the filter when it DOES work, but still...) I also added a line which frees the second temporary surface... it's weird that was missing in the first place, but I think reimplementing analogue mode was one of the last things I did for the renderer rewrite anyways. Resolves #1223.