added checking pointer
authorHolger Schemel <info@artsoft.org>
Wed, 8 Mar 2023 19:56:54 +0000 (20:56 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 8 Mar 2023 20:12:32 +0000 (21:12 +0100)
src/files.c
src/libgame/sound.c

index 39f145f539e1752a05c7a0a7e40e93fd11947055..7d0f6f0aff81becd92c1496e02263d5bf9fe1ace 100644 (file)
@@ -13007,9 +13007,16 @@ void LoadMusicInfo(void)
 
   // if all levels have game music configured, do not read music from directory
   if (!checkLevelSetHasMusic_NoConf())
+  {
     read_music_from_directory = FALSE;
+  }
+  else if (music_directory == NULL)
+  {
+    Warn("cannot find music directory with unconfigured music");
 
-  if ((dir = openDirectory(music_directory)) == NULL)
+    read_music_from_directory = FALSE;
+  }
+  else if ((dir = openDirectory(music_directory)) == NULL)
   {
     Warn("cannot read music directory '%s'", music_directory);
 
index 3d085a9dbe8f8f336d241978616723cbcb8ec465..a87b0dbcc3ad0241dd99b9b79a01d4cc9cc7f404 100644 (file)
@@ -609,7 +609,15 @@ static void LoadCustomMusic_NoConf(void)
 
   FreeAllMusic_NoConf();
 
-  if ((dir = openDirectory(music_directory)) == NULL)
+  if (music_directory == NULL)
+  {
+    Warn("cannot find music directory with unconfigured music");
+
+    audio.music_available = FALSE;
+
+    return;
+  }
+  else if ((dir = openDirectory(music_directory)) == NULL)
   {
     Warn("cannot read music directory '%s'", music_directory);