Skip to content

Commit

Permalink
Reset music.ctxType if loading wasn't succesful (raysan5#3917)
Browse files Browse the repository at this point in the history
Fixes some crashes, e.g. calling StopMusicStream after trying to load Music from a non-existant .mp3 file
  • Loading branch information
veins1 authored Apr 13, 2024
1 parent 583f81f commit 289e7d3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/raudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,7 @@ Music LoadMusicStream(const char *fileName)
#endif

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

music.ctxData = NULL;
music.ctxType = MUSIC_AUDIO_NONE;
TRACELOG(LOG_WARNING, "FILEIO: Music data could not be loaded");
}
else
Expand Down

0 comments on commit 289e7d3

Please sign in to comment.