From 67b6a763c3f892c637c8d63b4140527271c98e84 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Fri, 29 Jul 2022 17:07:36 +0200 Subject: [PATCH] Fix null pointer dereferences found by clang-tidy --- src/character.c | 2 +- src/internal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/character.c b/src/character.c index b121a37..67ea6dd 100644 --- a/src/character.c +++ b/src/character.c @@ -635,7 +635,7 @@ SYMBOL_EXPORT void AnimateCharacter(struct Game* game, struct Character* charact int pos = character->pos; - while (character->delta >= character->frame->duration) { + while (character->frame && character->delta >= character->frame->duration) { bool reachedEnd = false; character->delta -= character->frame->duration; diff --git a/src/internal.c b/src/internal.c index 9706de8..fa4551a 100644 --- a/src/internal.c +++ b/src/internal.c @@ -57,7 +57,7 @@ SYMBOL_INTERNAL void DrawGamestates(struct Game* game) { } tmp = tmp->next; } - if (game->loading.shown && game->_priv.loading.gamestate->api->predraw) { + if (game->loading.shown && game->_priv.loading.gamestate && game->_priv.loading.gamestate->api->predraw) { game->_priv.current_gamestate = game->_priv.loading.gamestate; game->_priv.loading.gamestate->api->predraw(game, game->_priv.loading.gamestate->data); }