diff -r ca42efdce3ce -r 31756e21c436 openalbridge/loaders.c --- a/openalbridge/loaders.c Sun Jul 12 15:42:54 2009 +0000 +++ b/openalbridge/loaders.c Sun Jul 12 19:12:08 2009 +0000 @@ -132,8 +132,7 @@ OggVorbis_File oggStream; /*stream handle*/ vorbis_info *vorbisInfo; /*some formatting data*/ int64_t pcm_length; /*length of the decoded data*/ - int size = 0; - int section, result; + int section, result, size = 0; #ifdef DEBUG int i; vorbis_comment *vorbisComment; /*other less useful data*/ @@ -141,7 +140,6 @@ oggFile = Fopen(filename, "rb"); result = ov_open(oggFile, &oggStream, NULL, 0); /*TODO: check returning value of result*/ - fclose(oggFile); vorbisInfo = ov_info(&oggStream, -1); pcm_length = ov_pcm_total(&oggStream, -1) << vorbisInfo->channels; @@ -173,6 +171,8 @@ *format = AL_FORMAT_STEREO16; else { fprintf(stderr, "ERROR: wrong OGG header - channel value (%d)\n", vorbisInfo->channels); + ov_clear (&oggStream); + fclose(oggFile); return AL_FALSE; } } @@ -187,6 +187,8 @@ break; else { fprintf(stderr, "ERROR: end of file from OGG stream\n"); + ov_clear (&oggStream); + fclose(oggFile); return AL_FALSE; } } @@ -197,6 +199,7 @@ *freq = vorbisInfo->rate; ov_clear (&oggStream); + fclose (oggFile); return AL_TRUE; }