From 1334fc6b1d72d253050ba24bd74721845658f22e Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Fri, 11 Jan 2019 15:25:24 +0100 Subject: [PATCH] fix a NULL pointer dereference in ResizeGamestates --- src/internal.c | 12 +++++++----- src/utils.c | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/internal.c b/src/internal.c index 9eb67d9..2866096 100644 --- a/src/internal.c +++ b/src/internal.c @@ -167,11 +167,13 @@ SYMBOL_INTERNAL void ResizeGamestates(struct Game* game) { } tmp = tmp->next; } - al_destroy_bitmap(game->_priv.loading.gamestate->fb); - if (game->_priv.params.handlers.compositor) { - game->_priv.loading.gamestate->fb = CreateNotPreservedBitmap(game->clip_rect.w, game->clip_rect.h); - } else { - game->_priv.loading.gamestate->fb = al_create_sub_bitmap(al_get_backbuffer(game->display), game->clip_rect.x, game->clip_rect.y, game->clip_rect.w, game->clip_rect.h); + if (game->_priv.loading.gamestate) { + al_destroy_bitmap(game->_priv.loading.gamestate->fb); + if (game->_priv.params.handlers.compositor) { + game->_priv.loading.gamestate->fb = CreateNotPreservedBitmap(game->clip_rect.w, game->clip_rect.h); + } else { + game->_priv.loading.gamestate->fb = al_create_sub_bitmap(al_get_backbuffer(game->display), game->clip_rect.x, game->clip_rect.y, game->clip_rect.w, game->clip_rect.h); + } } } diff --git a/src/utils.c b/src/utils.c index 1df6e24..9e0d5ca 100644 --- a/src/utils.c +++ b/src/utils.c @@ -458,6 +458,7 @@ SYMBOL_EXPORT void PrintConsoleWithContext(struct Game* game, int line, const ch fflush(stdout); #endif } + game->_priv.console_pos++; if (game->_priv.console_pos >= (sizeof(game->_priv.console) / sizeof(game->_priv.console[0]))) { game->_priv.console_pos = 0;