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
This commit is contained in:
veins1
2024-04-14 03:15:50 +05:00
committed by GitHub
parent 583f81f458
commit 289e7d3a6c

View File

@@ -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