From ccb083af52989c8681aa8047cd6380f7081d3381 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 14 Feb 2021 16:37:34 +0000 Subject: [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. --- src/external/jar_xm.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/external') diff --git a/src/external/jar_xm.h b/src/external/jar_xm.h index 1839e619..bfd63ec0 100644 --- a/src/external/jar_xm.h +++ b/src/external/jar_xm.h @@ -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) { -- cgit v1.2.3