From 1a96516cabe977f88568dfc4ef2e6948b6dae2e2 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 24 Jun 2014 14:26:38 +0000 Subject: [PATCH] Correct two more corner case problems with #1486: 1) single-page streams will have no bisection; handle the special case explicitly 2) if the bisection fails without ever successfully grabbing a page, the first-page-special-case check is unprotected and will look at uninitialized memory. svn path=/trunk/vorbis/; revision=19171 --- lib/vorbisfile.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/vorbisfile.c b/lib/vorbisfile.c index 1b7f80a..93f663c 100644 --- a/lib/vorbisfile.c +++ b/lib/vorbisfile.c @@ -1437,8 +1437,21 @@ int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos){ ogg_int64_t endtime = vf->pcmlengths[link*2+1]+begintime; ogg_int64_t target=pos-total+begintime; ogg_int64_t best=-1; + int got_page=0; ogg_page og; + + /* if we have only one page, there will be no bisection. Grab the page here */ + if(begin==end){ + result=_seek_helper(vf,begin); + if(result) goto seek_error; + + result=_get_next_page(vf,&og,1); + if(result<0) goto seek_error; + + got_page=1; + } + /* bisection loop */ while(begindataoffsets[link] && + if(got_page && + begin == vf->dataoffsets[link] && ogg_page_serialno(&og)==vf->serialnos[link]){ /* Yes, this is the beginning-of-stream case. We already have -- 2.7.4