[xiph-commits] r15927 - trunk/vorbis/lib

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Thu Apr 9 02:02:06 PDT 2009


Author: xiphmont
Date: 2009-04-09 02:02:06 -0700 (Thu, 09 Apr 2009)
New Revision: 15927

Modified:
   trunk/vorbis/lib/vorbisfile.c
Log:
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.



Modified: trunk/vorbis/lib/vorbisfile.c
===================================================================
--- trunk/vorbis/lib/vorbisfile.c	2009-04-09 07:23:28 UTC (rev 15926)
+++ trunk/vorbis/lib/vorbisfile.c	2009-04-09 09:02:06 UTC (rev 15927)
@@ -284,6 +284,7 @@
     
     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 @@
   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 _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 @@
 
   /* 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 @@
 	    
 	    /* 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 @@
     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;
   }



More information about the commits mailing list