diff --git a/src/app/gfx/bitmap.h b/src/app/gfx/bitmap.h index 797db5b6..2270f5ab 100644 --- a/src/app/gfx/bitmap.h +++ b/src/app/gfx/bitmap.h @@ -46,8 +46,14 @@ class Bitmap { private: struct sdl_deleter { - void operator()(SDL_Texture *p) const { SDL_DestroyTexture(p); } - void operator()(SDL_Surface *p) const { SDL_FreeSurface(p); } + void operator()(SDL_Texture *p) const { + SDL_DestroyTexture(p); + p = nullptr; + } + void operator()(SDL_Surface *p) const { + SDL_FreeSurface(p); + p = nullptr; + } }; int width_ = 0; @@ -57,8 +63,8 @@ class Bitmap { bool freed_ = false; uchar *pixel_data_; Bytes data_; - std::shared_ptr texture_; - std::shared_ptr surface_; + std::shared_ptr texture_ = nullptr; + std::shared_ptr surface_ = nullptr; }; } // namespace gfx