From: Holger Schemel Date: Tue, 30 Apr 2024 20:32:43 +0000 (+0200) Subject: added some safety checks X-Git-Tag: 4.4.0.0-test-1~21 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=bd7e53746a73c5405f8918cf835820b3aac349b7;p=rocksndiamonds.git added some safety checks --- 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++) {