From bd7e53746a73c5405f8918cf835820b3aac349b7 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 30 Apr 2024 22:32:43 +0200 Subject: [PATCH] added some safety checks --- src/game_bd/bd_caveset.c | 7 +++++-- src/tools.c | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/game_bd/bd_caveset.c b/src/game_bd/bd_caveset.c index d83a1b97..0ee9c3b8 100644 --- a/src/game_bd/bd_caveset.c +++ b/src/game_bd/bd_caveset.c @@ -87,7 +87,8 @@ GdCavesetData *gd_caveset_data_new(void) gd_struct_set_defaults_from_array(data, gd_caveset_properties, caveset_defaults); - data->levelset_subdir = getStringCopy(leveldir_current->subdir); + if (leveldir_current != NULL) + data->levelset_subdir = getStringCopy(leveldir_current->subdir); return data; } @@ -129,7 +130,9 @@ void gd_caveset_clear(void) // always newly create this // create pseudo cave containing default values gd_caveset_data = gd_caveset_data_new(); - gd_strcpy(gd_caveset_data->name, leveldir_current->name); + + if (leveldir_current != NULL) + gd_strcpy(gd_caveset_data->name, leveldir_current->name); } // return number of caves currently in memory. diff --git a/src/tools.c b/src/tools.c index 954e7a63..a4cabfda 100644 --- a/src/tools.c +++ b/src/tools.c @@ -10710,6 +10710,9 @@ void InitGraphicInfo_BD(void) { int i, j; + if (graphic_info == NULL) // still at startup phase + return; + // always start with reliable default values for (i = 0; i < O_MAX_ALL; i++) { -- 2.34.1