[raudio] Fix load and unload issues with Music (#1588)

* Add MUSIC_AUDIO_NONE to MusicContextType and format fixes
- Useful to check the context type to see if the format is recognized. Defaulting to wav causes issues where formats are assumed to
be wav.

* Fix memory issues with LoadMusicStream and UnloadMusicStream
- Set ctxType and ctxData even if the format fails to load.
- Set ctxData to NULL if it fails and check for null inside UnloadMusicStream.
- Change RL_MALLOC when loading formats to RL_CALLOC to prevent undefined behavior.
- Add NULL check when unloading xm file.
This commit is contained in:
Chris
2021-02-14 16:37:34 +00:00
committed by GitHub
parent c7476f0aa5
commit ccb083af52
2 changed files with 38 additions and 35 deletions

View File

@ -696,7 +696,9 @@ int jar_xm_create_context_safe(jar_xm_context_t** ctxp, const char* moddata, siz
}
void jar_xm_free_context(jar_xm_context_t* ctx) {
JARXM_FREE(ctx->allocated_memory);
if (ctx != NULL) {
JARXM_FREE(ctx->allocated_memory);
}
}
void jar_xm_set_max_loop_count(jar_xm_context_t* ctx, uint8_t loopcnt) {