From e51960b3a2c5071b5c4229fb478d21b40894c35d Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Mon, 19 Jun 2017 23:06:53 +0000 Subject: [PATCH] Fix memory leaks in audiolib. Fixes issue #59. git-svn-id: https://svn.eduke32.com/eduke32@6202 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/audiolib/src/flac.cpp | 1 + source/audiolib/src/vorbis.cpp | 1 + source/audiolib/src/xmp.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/source/audiolib/src/flac.cpp b/source/audiolib/src/flac.cpp index 1fe1fdd6f..4ee9e5344 100644 --- a/source/audiolib/src/flac.cpp +++ b/source/audiolib/src/flac.cpp @@ -462,6 +462,7 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t lo /*metadata_flac_stream*/ NULL, error_flac_stream, (void *)fd) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { + free(fd); MV_Printf("MV_PlayFLAC: %s\n", FLAC__stream_decoder_get_resolved_state_string(fd->stream)); MV_SetErrorCode(MV_InvalidFile); return MV_Error; diff --git a/source/audiolib/src/vorbis.cpp b/source/audiolib/src/vorbis.cpp index 19f31a0ea..9d16cb0bc 100644 --- a/source/audiolib/src/vorbis.cpp +++ b/source/audiolib/src/vorbis.cpp @@ -398,6 +398,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t if (status < 0) { + free(vd); MV_Printf("MV_PlayVorbis: err %d\n", status); MV_SetErrorCode(MV_InvalidFile); return MV_Error; diff --git a/source/audiolib/src/xmp.cpp b/source/audiolib/src/xmp.cpp index fe630d050..11a613bae 100644 --- a/source/audiolib/src/xmp.cpp +++ b/source/audiolib/src/xmp.cpp @@ -138,6 +138,7 @@ int32_t MV_PlayXMP(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loo if ((retval = xmp_load_module_from_memory(xmpd->context, ptr, ptrlength)) != 0) { + free(xmpd); MV_Printf("MV_PlayXMP: xmp_load_module_from_memory failed (%i)\n", retval); MV_SetErrorCode(MV_InvalidFile); return MV_Error;