From aebe17d34fc6f7ff3a1bc48ca5da73a0e1762ad0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 14 Aug 2017 16:34:54 -0700 Subject: [PATCH] Fixed bug 2344 - CHECK_WINDOW_MAGIC should include __FILE__ and __LINE__ Martin Gerhardy just for easier debugging issues in the own code... SDL_CreateRenderer should maybe also use this macro Ryan C. Gordon I'll go one better: it should have an SDL_assert(). --- src/render/SDL_render.c | 2 ++ src/video/SDL_video.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index cf80cfb8c..d5030fea8 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -33,12 +33,14 @@ #define SDL_WINDOWRENDERDATA "_SDL_WindowRenderData" #define CHECK_RENDERER_MAGIC(renderer, retval) \ + SDL_assert(renderer && renderer->magic == &renderer_magic); \ if (!renderer || renderer->magic != &renderer_magic) { \ SDL_SetError("Invalid renderer"); \ return retval; \ } #define CHECK_TEXTURE_MAGIC(texture, retval) \ + SDL_assert(texture && texture->magic == &texture_magic); \ if (!texture || texture->magic != &texture_magic) { \ SDL_SetError("Invalid texture"); \ return retval; \ diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 2f15ec528..8f7834c0f 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -130,6 +130,7 @@ static SDL_VideoDevice *_this = NULL; SDL_UninitializedVideo(); \ return retval; \ } \ + SDL_assert(window && window->magic == &_this->window_magic); \ if (!window || window->magic != &_this->window_magic) { \ SDL_SetError("Invalid window"); \ return retval; \ @@ -141,6 +142,7 @@ static SDL_VideoDevice *_this = NULL; return retval; \ } \ SDL_assert(_this->displays != NULL); \ + SDL_assert(displayIndex >= 0 && displayIndex < _this->num_displays); \ if (displayIndex < 0 || displayIndex >= _this->num_displays) { \ SDL_SetError("displayIndex must be in the range 0 - %d", \ _this->num_displays - 1); \