Browse Source

Reset music.ctxType if loading wasn't succesful (#3917)

Fixes some crashes, e.g. calling StopMusicStream after trying to load Music from a non-existant .mp3 file
veins1 1 year ago
parent
commit
289e7d3a6c
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/raudio.c

+ 2 - 0
src/raudio.c

@@ -1461,6 +1461,7 @@ Music LoadMusicStream(const char *fileName)
     #endif
     #endif
 
 
         music.ctxData = NULL;
         music.ctxData = NULL;
+        music.ctxType = MUSIC_AUDIO_NONE;
         TRACELOG(LOG_WARNING, "FILEIO: [%s] Music file could not be opened", fileName);
         TRACELOG(LOG_WARNING, "FILEIO: [%s] Music file could not be opened", fileName);
     }
     }
     else
     else
@@ -1670,6 +1671,7 @@ Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data,
 #endif
 #endif
 
 
         music.ctxData = NULL;
         music.ctxData = NULL;
+        music.ctxType = MUSIC_AUDIO_NONE;
         TRACELOG(LOG_WARNING, "FILEIO: Music data could not be loaded");
         TRACELOG(LOG_WARNING, "FILEIO: Music data could not be loaded");
     }
     }
     else
     else