From 1c2e27f2b7a05696fc5568fd71b6ca63d2719f94 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Thu, 19 Jul 2018 01:39:53 +0200 Subject: [PATCH] fix potential crash shown by clang-tidy warning --- src/internal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/internal.c b/src/internal.c index bb351d4..856cd71 100644 --- a/src/internal.c +++ b/src/internal.c @@ -295,7 +295,7 @@ SYMBOL_INTERNAL bool OpenGamestate(struct Game* game, struct Gamestate* gamestat } SYMBOL_INTERNAL bool LinkGamestate(struct Game* game, struct Gamestate* gamestate) { - gamestate->api = malloc(sizeof(struct Gamestate_API)); + gamestate->api = calloc(1, sizeof(struct Gamestate_API)); #define GS_ERROR \ FatalError(game, false, "Error on resolving gamestate's %s symbol: %s", gamestate->name, dlerror()); /* TODO: move out */ \ @@ -552,8 +552,12 @@ SYMBOL_INTERNAL void ResumeExecution(struct Game* game) { if (tmp->api->Gamestate_Reload) { tmp->api->Gamestate_Reload(game, tmp->data); } + } else { + // live-reload failed + tmp->loaded = false; } } + if (!tmp->paused && tmp->loaded && tmp->api->Gamestate_Resume) { tmp->api->Gamestate_Resume(game, tmp->data); }