Fix free of uninitialized memory if seek fails in ov_raw_seek
authorJames Cowgill <jcowgill@debian.org>
Tue, 13 Jun 2017 12:39:52 +0000 (13:39 +0100)
committerThomas Daede <daede003@umn.edu>
Mon, 28 Jan 2019 23:01:26 +0000 (15:01 -0800)
commit128f0f812b39185d884c67c5f1c780b19aca34ac
treef93770cfc00308a46986721e6a5bb47d32391109
parent7e89d68b46200519edfd09196f672c29147c8d33
Fix free of uninitialized memory if seek fails in ov_raw_seek

If _seek_helper fails in ov_raw_seek, control jumps to the seek_error
label which calls ogg_stream_clear on work_os. However, at this point
in the function, work_os is not initialized so we end up attempting to
free some uninitialized memory and crashing.

Fix by removing the call to ogg_stream_clear. This is safe because the
only code path to seek_error happens before work_os is initialized (so
there is never anything to free anyway).

I also refactor the code a bit:
- Remove the ret variable which is unnessesary since we can just pass
  the result of _seek_helper directly to the if.
- Since seek_error is only used once, move the contents of that block
  to the if statement so we can remove a goto.
lib/vorbisfile.c