From c623230861ad880b17a9f7b1c1fd66742d48f56d Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 3 Sep 2022 18:30:12 -0500 Subject: [PATCH] tinfoil hat --- src/app/gfx/bitmap.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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