vorbisfile: fclose not always called by ov_clear
I don't know if this is a bug in the documentation or in the implementation.
The comment in /browser/trunk/vorbis/lib/vorbisfile.c#L1058 suggests ov_test followed by ov_clear should close the file, but that currently doesn't happen in the error case.
Line 915 sets vf->datasource to NULL
Then whenever ov_clear is called (either in the following line, or by the user) fclose is not called due to the check in line 975.
The workaround in my calling code looks like this:
FILE * test_file = NULL;
test_file = fopen(filename.c_str(), "rb");
if(test_file == NULL)
return false;
OggVorbis_File test_ovfile;
int res = ov_test(test_file, &test_ovfile, NULL, 0);
// ov_clear is supposed to close the file but for some ov_test code paths
// this doesn't work, as the internal file pointer is set NULL. We'll do
// the fclose ourselves to be sure
fclose(test_file);
test_ovfile.datasource = NULL;
ov_clear(&test_ovfile);