diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index c103881..16f17ab 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -38,7 +38,8 @@ Renderer::Renderer(Window& window, int index, Uint32 flags) { } Renderer::~Renderer() { - SDL_DestroyRenderer(renderer_); + if (renderer_ != nullptr) + SDL_DestroyRenderer(renderer_); } Renderer::Renderer(Renderer&& other) noexcept : renderer_(other.renderer_) { diff --git a/SDL2pp/Texture.cc b/SDL2pp/Texture.cc index 31f2147..fa01f88 100644 --- a/SDL2pp/Texture.cc +++ b/SDL2pp/Texture.cc @@ -36,7 +36,8 @@ Texture::Texture(Renderer& renderer, Uint32 format, int access, int w, int h) { } Texture::~Texture() { - SDL_DestroyTexture(texture_); + if (texture_ != nullptr) + SDL_DestroyTexture(texture_); } Texture::Texture(Texture&& other) noexcept : texture_(other.texture_) { diff --git a/SDL2pp/Window.cc b/SDL2pp/Window.cc index 232f960..f6458ac 100644 --- a/SDL2pp/Window.cc +++ b/SDL2pp/Window.cc @@ -32,7 +32,8 @@ Window::Window(const char* title, int x, int y, int w, int h, Uint32 flags) { } Window::~Window() { - SDL_DestroyWindow(window_); + if (window_ != nullptr) + SDL_DestroyWindow(window_); } Window::Window(Window&& other) noexcept : window_(other.window_) {