mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-06 14:44:25 +01:00
Fixed file handle leak in HCA and MP4 decoders. Minor casting fixes.
This commit is contained in:
parent
355ed06781
commit
5200ed4a91
@ -15,8 +15,6 @@ VGMSTREAM * init_vgmstream_hca_offset(STREAMFILE *streamFile, uint64_t start, ui
|
|||||||
|
|
||||||
VGMSTREAM * vgmstream = NULL;
|
VGMSTREAM * vgmstream = NULL;
|
||||||
|
|
||||||
char filename[PATH_LIMIT];
|
|
||||||
|
|
||||||
hca_codec_data * hca_file = ( hca_codec_data * ) calloc(1, sizeof(hca_codec_data) + clHCA_sizeof());
|
hca_codec_data * hca_file = ( hca_codec_data * ) calloc(1, sizeof(hca_codec_data) + clHCA_sizeof());
|
||||||
void * hca_data = NULL;
|
void * hca_data = NULL;
|
||||||
clHCA * hca;
|
clHCA * hca;
|
||||||
@ -60,11 +58,6 @@ VGMSTREAM * init_vgmstream_hca_offset(STREAMFILE *streamFile, uint64_t start, ui
|
|||||||
hca_file->sample_ptr = clHCA_samplesPerBlock;
|
hca_file->sample_ptr = clHCA_samplesPerBlock;
|
||||||
hca_file->samples_discard = 0;
|
hca_file->samples_discard = 0;
|
||||||
|
|
||||||
streamFile->get_name( streamFile, filename, sizeof(filename) );
|
|
||||||
|
|
||||||
hca_file->streamfile = streamFile->open(streamFile, filename, STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
||||||
if (!hca_file->streamfile) goto fail;
|
|
||||||
|
|
||||||
vgmstream = allocate_vgmstream( hca_file->info.channelCount, 1 );
|
vgmstream = allocate_vgmstream( hca_file->info.channelCount, 1 );
|
||||||
if (!vgmstream) goto fail;
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
@ -127,11 +127,6 @@ VGMSTREAM * init_vgmstream_mp4_aac_offset(STREAMFILE *streamFile, uint64_t start
|
|||||||
aac_file->samples_per_frame = stream_info->frameSize;
|
aac_file->samples_per_frame = stream_info->frameSize;
|
||||||
aac_file->samples_discard = 0;
|
aac_file->samples_discard = 0;
|
||||||
|
|
||||||
streamFile->get_name( streamFile, filename, sizeof(filename) );
|
|
||||||
|
|
||||||
aac_file->if_file.streamfile = streamFile->open(streamFile, filename, STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
||||||
if (!aac_file->if_file.streamfile) goto fail;
|
|
||||||
|
|
||||||
vgmstream = allocate_vgmstream( stream_info->numChannels, 1 );
|
vgmstream = allocate_vgmstream( stream_info->numChannels, 1 );
|
||||||
if (!vgmstream) goto fail;
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
@ -619,7 +619,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
|
|
||||||
#ifdef VGM_USE_VORBIS
|
#ifdef VGM_USE_VORBIS
|
||||||
if (vgmstream->coding_type==coding_ogg_vorbis) {
|
if (vgmstream->coding_type==coding_ogg_vorbis) {
|
||||||
ogg_vorbis_codec_data *data = vgmstream->codec_data;
|
ogg_vorbis_codec_data *data = (ogg_vorbis_codec_data *) vgmstream->codec_data;
|
||||||
if (vgmstream->codec_data) {
|
if (vgmstream->codec_data) {
|
||||||
OggVorbis_File *ogg_vorbis_file = &(data->ogg_vorbis_file);
|
OggVorbis_File *ogg_vorbis_file = &(data->ogg_vorbis_file);
|
||||||
|
|
||||||
@ -631,8 +631,11 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vgmstream->coding_type==coding_CRI_HCA) {
|
if (vgmstream->coding_type==coding_CRI_HCA) {
|
||||||
|
hca_codec_data *data = (hca_codec_data *) vgmstream->codec_data;
|
||||||
if (vgmstream->codec_data) {
|
if (vgmstream->codec_data) {
|
||||||
|
if (data->streamfile) close_streamfile(data->streamfile);
|
||||||
free(vgmstream->codec_data);
|
free(vgmstream->codec_data);
|
||||||
vgmstream->codec_data = NULL;
|
vgmstream->codec_data = NULL;
|
||||||
}
|
}
|
||||||
@ -640,7 +643,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
|
|
||||||
#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC)
|
#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC)
|
||||||
if (vgmstream->coding_type==coding_MP4_AAC) {
|
if (vgmstream->coding_type==coding_MP4_AAC) {
|
||||||
mp4_aac_codec_data *data = vgmstream->codec_data;
|
mp4_aac_codec_data *data = (mp4_aac_codec_data *) vgmstream->codec_data;
|
||||||
if (vgmstream->codec_data) {
|
if (vgmstream->codec_data) {
|
||||||
if (data->h_aacdecoder) aacDecoder_Close(data->h_aacdecoder);
|
if (data->h_aacdecoder) aacDecoder_Close(data->h_aacdecoder);
|
||||||
if (data->h_mp4file) MP4Close(data->h_mp4file, 0);
|
if (data->h_mp4file) MP4Close(data->h_mp4file, 0);
|
||||||
@ -654,7 +657,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
#ifdef VGM_USE_MPEG
|
#ifdef VGM_USE_MPEG
|
||||||
if (vgmstream->layout_type==layout_fake_mpeg||
|
if (vgmstream->layout_type==layout_fake_mpeg||
|
||||||
vgmstream->layout_type==layout_mpeg) {
|
vgmstream->layout_type==layout_mpeg) {
|
||||||
mpeg_codec_data *data = vgmstream->codec_data;
|
mpeg_codec_data *data = (mpeg_codec_data *) vgmstream->codec_data;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
mpg123_delete(data->m);
|
mpg123_delete(data->m);
|
||||||
@ -673,7 +676,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
if (vgmstream->coding_type == coding_G7221 ||
|
if (vgmstream->coding_type == coding_G7221 ||
|
||||||
vgmstream->coding_type == coding_G7221C) {
|
vgmstream->coding_type == coding_G7221C) {
|
||||||
|
|
||||||
g7221_codec_data *data = vgmstream->codec_data;
|
g7221_codec_data *data = (g7221_codec_data *) vgmstream->codec_data;
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
@ -692,7 +695,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
|
|
||||||
#ifdef VGM_USE_G719
|
#ifdef VGM_USE_G719
|
||||||
if (vgmstream->coding_type == coding_G719) {
|
if (vgmstream->coding_type == coding_G719) {
|
||||||
g719_codec_data *data = vgmstream->codec_data;
|
g719_codec_data *data = (g719_codec_data *) vgmstream->codec_data;
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
@ -711,7 +714,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
|
|
||||||
#ifdef VGM_USE_MAIATRAC3PLUS
|
#ifdef VGM_USE_MAIATRAC3PLUS
|
||||||
if (vgmstream->coding_type == coding_AT3plus) {
|
if (vgmstream->coding_type == coding_AT3plus) {
|
||||||
maiatrac3plus_codec_data *data = vgmstream->codec_data;
|
maiatrac3plus_codec_data *data = (maiatrac3plus_codec_data *) vgmstream->codec_data;
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
@ -722,7 +725,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vgmstream->coding_type==coding_ACM) {
|
if (vgmstream->coding_type==coding_ACM) {
|
||||||
mus_acm_codec_data *data = vgmstream->codec_data;
|
mus_acm_codec_data *data = (mus_acm_codec_data *) vgmstream->codec_data;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data->files) {
|
if (data->files) {
|
||||||
@ -744,7 +747,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vgmstream->layout_type==layout_aix) {
|
if (vgmstream->layout_type==layout_aix) {
|
||||||
aix_codec_data *data = vgmstream->codec_data;
|
aix_codec_data *data = (aix_codec_data *) vgmstream->codec_data;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data->adxs) {
|
if (data->adxs) {
|
||||||
@ -767,7 +770,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
vgmstream->codec_data = NULL;
|
vgmstream->codec_data = NULL;
|
||||||
}
|
}
|
||||||
if (vgmstream->layout_type==layout_aax) {
|
if (vgmstream->layout_type==layout_aax) {
|
||||||
aax_codec_data *data = vgmstream->codec_data;
|
aax_codec_data *data = (aax_codec_data *) vgmstream->codec_data;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data->adxs) {
|
if (data->adxs) {
|
||||||
@ -798,7 +801,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
vgmstream->coding_type == coding_NWA4 ||
|
vgmstream->coding_type == coding_NWA4 ||
|
||||||
vgmstream->coding_type == coding_NWA5
|
vgmstream->coding_type == coding_NWA5
|
||||||
) {
|
) {
|
||||||
nwa_codec_data *data = vgmstream->codec_data;
|
nwa_codec_data *data = (nwa_codec_data *) vgmstream->codec_data;
|
||||||
|
|
||||||
close_nwa(data->nwa);
|
close_nwa(data->nwa);
|
||||||
|
|
||||||
@ -808,7 +811,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vgmstream->layout_type==layout_scd_int) {
|
if (vgmstream->layout_type==layout_scd_int) {
|
||||||
scd_int_codec_data *data = vgmstream->codec_data;
|
scd_int_codec_data *data = (scd_int_codec_data *) vgmstream->codec_data;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data->substreams) {
|
if (data->substreams) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user