Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
Vorbis
Vorbis
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Xiph.Org
  • VorbisVorbis
  • Issues
  • #1965

Closed
Open
Opened Jul 02, 2013 by tangobravo@tangobravo

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);
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: xiph/vorbis#1965