From f3eb31766a75d57d69b2e30e30d385f90bf1b875 Mon Sep 17 00:00:00 2001 From: scawful Date: Wed, 17 Aug 2022 14:47:06 -0400 Subject: [PATCH] chore: add conditional to freeing Bitmap --- src/app/gfx/bitmap.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/gfx/bitmap.h b/src/app/gfx/bitmap.h index ea6ac855..416a3dca 100644 --- a/src/app/gfx/bitmap.h +++ b/src/app/gfx/bitmap.h @@ -40,14 +40,15 @@ 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 { if (p) { SDL_DestroyTexture(p); p = nullptr; } } + void operator()(SDL_Surface *p) const { if (p) { SDL_FreeSurface(p); p = nullptr;} } }; int width_ = 0; int height_ = 0; int depth_ = 0; int data_size_ = 0; + bool freed_ = false; uchar *pixel_data_; std::shared_ptr texture_; std::shared_ptr surface_;