Fix file handle leak in vgmstream decoder.
This commit is contained in:
parent
27e5402d88
commit
ed33e37214
1 changed files with 11 additions and 6 deletions
|
@ -110,15 +110,13 @@ VGMSTREAM *init_vgmstream_from_cogfile(const char *path) {
|
||||||
VGMSTREAM *vgm;
|
VGMSTREAM *vgm;
|
||||||
|
|
||||||
sf = cogsf_create_from_path(path);
|
sf = cogsf_create_from_path(path);
|
||||||
if (!sf) return NULL;
|
|
||||||
|
|
||||||
vgm = init_vgmstream_from_STREAMFILE(sf);
|
if (sf) {
|
||||||
if (!vgm) goto err1;
|
vgm = init_vgmstream_from_STREAMFILE(sf);
|
||||||
|
cogsf_close((COGSTREAMFILE *)sf);
|
||||||
|
}
|
||||||
|
|
||||||
return vgm;
|
return vgm;
|
||||||
err1:
|
|
||||||
cogsf_close((COGSTREAMFILE *)sf);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation VGMDecoder
|
@implementation VGMDecoder
|
||||||
|
@ -195,6 +193,13 @@ err1:
|
||||||
|
|
||||||
- (long)seek:(long)frame
|
- (long)seek:(long)frame
|
||||||
{
|
{
|
||||||
|
// Constrain the seek offset to within the loop, if any
|
||||||
|
if(stream->loop_flag && (stream->loop_end_sample - stream->loop_start_sample) && frame >= stream->loop_end_sample) {
|
||||||
|
frame -= stream->loop_start_sample;
|
||||||
|
frame %= (stream->loop_end_sample - stream->loop_start_sample);
|
||||||
|
frame += stream->loop_start_sample;
|
||||||
|
}
|
||||||
|
|
||||||
if (frame < framesRead) {
|
if (frame < framesRead) {
|
||||||
reset_vgmstream( stream );
|
reset_vgmstream( stream );
|
||||||
framesRead = 0;
|
framesRead = 0;
|
||||||
|
|
Loading…
Reference in a new issue