diff options
author | Monty <xiphmont@xiph.org> | 2009-04-09 09:02:06 +0000 |
---|---|---|
committer | Monty <xiphmont@xiph.org> | 2009-04-09 09:02:06 +0000 |
commit | c62e2bd601db5002f36d851d15dd19374d5aae89 (patch) | |
tree | 9f5968a571e5f0364737e7ac33ec35c335a2cf65 | |
parent | 000d0bd190e7466e3d4027466dff003ece10570e (diff) | |
download | libvorbis-git-c62e2bd601db5002f36d851d15dd19374d5aae89.tar.gz |
Nip a potential bug in the bud (open2 was relying on the position of the vf->offset cursor not being disturbed from open1)
Fill in offsets and dataoffsets fileds in VF struct, even for non-seekable streams.
svn path=/trunk/vorbis/; revision=15927
-rw-r--r-- | lib/vorbisfile.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/vorbisfile.c b/lib/vorbisfile.c index a765c3e7..88a53fc8 100644 --- a/lib/vorbisfile.c +++ b/lib/vorbisfile.c @@ -284,6 +284,7 @@ static int _bisect_forward_serialno(OggVorbis_File *vf, if(searched>=end || next_serialnos==0){ vf->links=m+1; + if(vf->offsets)_ogg_free(vf->offsets); vf->offsets=_ogg_malloc((vf->links+1)*sizeof(*vf->offsets)); vf->offsets[m+1]=searched; }else{ @@ -450,8 +451,8 @@ static void _prefetch_all_headers(OggVorbis_File *vf, ogg_int64_t dataoffset){ int i; ogg_int64_t ret; - /* release any overloaded vf->serialnos state */ if(vf->serialnos)_ogg_free(vf->serialnos); + if(vf->dataoffsets)_ogg_free(vf->dataoffsets); vf->vi=_ogg_realloc(vf->vi,vf->links*sizeof(*vf->vi)); vf->vc=_ogg_realloc(vf->vc,vf->links*sizeof(*vf->vc)); @@ -582,7 +583,7 @@ static int _make_decode_ready(OggVorbis_File *vf){ } static int _open_seekable2(OggVorbis_File *vf){ - ogg_int64_t dataoffset=vf->offset,end; + ogg_int64_t dataoffset=vf->dataoffsets[0],end; ogg_page og; /* we're partially open and have a first link header state in @@ -608,7 +609,7 @@ static int _open_seekable2(OggVorbis_File *vf){ /* the initial header memory is referenced by vf after; don't free it */ _prefetch_all_headers(vf,dataoffset); - return(ov_raw_seek(vf,0)); + return(ov_raw_seek(vf,dataoffset)); } /* clear out the current logical bitstream decoder */ @@ -737,7 +738,7 @@ static int _fetch_and_process_packet(OggVorbis_File *vf, /* two possibilities: 1) our decoding just traversed a bitstream boundary - 2) another stream is multiplexed into this logical section? */ + 2) another stream is multiplexed into this logical section */ if(ogg_page_bos(&og)){ /* boundary case */ @@ -877,6 +878,11 @@ static int _ov_open1(void *f,OggVorbis_File *vf,char *initial, vf->serialnos[0]=vf->current_serialno; vf->serialnos[1]=serialno_list_size; memcpy(vf->serialnos+2,serialno_list,serialno_list_size*sizeof(*vf->serialnos)); + + vf->offsets=_ogg_calloc(1,sizeof(*vf->offsets)); + vf->dataoffsets=_ogg_calloc(1,sizeof(*vf->dataoffsets)); + vf->offsets[0]=0; + vf->dataoffsets[0]=vf->offset; vf->ready_state=PARTOPEN; } |