[xiph-commits] r17526 - trunk/Tremor

tterribe at svn.xiph.org tterribe at svn.xiph.org
Wed Oct 13 18:09:06 PDT 2010


Author: tterribe
Date: 2010-10-13 18:09:06 -0700 (Wed, 13 Oct 2010)
New Revision: 17526

Modified:
   trunk/Tremor/block.c
   trunk/Tremor/ivorbisfile_example.c
Log:
Port r16328 and r16330 from libvorbis.

ivorbisfile_example.c ignores an error code and plows ahead blindly if
 libvorbisidec reports the current bitstream section is bad (OV_EBADLINK).
Retrying after the error crashes libvorbisidec due to the unitialized state.


Modified: trunk/Tremor/block.c
===================================================================
--- trunk/Tremor/block.c	2010-10-14 01:05:50 UTC (rev 17525)
+++ trunk/Tremor/block.c	2010-10-14 01:09:06 UTC (rev 17526)
@@ -161,14 +161,16 @@
   b->window[1]=_vorbis_window(0,ci->blocksizes[1]/2);
 
   /* finish the codebooks */
-  if(!ci->fullbooks){
+  if(!ci->fullbooks)
     ci->fullbooks=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->fullbooks));
-    for(i=0;i<ci->books;i++){
-      vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]);
-      /* decode codebooks are now standalone after init */
-      vorbis_staticbook_destroy(ci->book_param[i]);
-      ci->book_param[i]=NULL;
-    }
+  for(i=0;i<ci->books;i++){
+    if(ci->book_param[i]==NULL)
+      goto abort_books;
+    if(vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]))
+      goto abort_books;
+    /* decode codebooks are now standalone after init */
+    vorbis_staticbook_destroy(ci->book_param[i]);
+    ci->book_param[i]=NULL;
   }
 
   v->pcm_storage=ci->blocksizes[1];
@@ -191,6 +193,15 @@
 					 ci->map_param[mapnum]);
   }
   return 0;
+abort_books:
+  for(i=0;i<ci->books;i++){
+    if(ci->book_param[i]!=NULL){
+      vorbis_staticbook_destroy(ci->book_param[i]);
+      ci->book_param[i]=NULL;
+    }
+  }
+  vorbis_dsp_clear(v);
+  return -1;
 }
 
 int vorbis_synthesis_restart(vorbis_dsp_state *v){

Modified: trunk/Tremor/ivorbisfile_example.c
===================================================================
--- trunk/Tremor/ivorbisfile_example.c	2010-10-14 01:05:50 UTC (rev 17525)
+++ trunk/Tremor/ivorbisfile_example.c	2010-10-14 01:09:06 UTC (rev 17526)
@@ -21,8 +21,8 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <vorbis/ivorbiscodec.h>
-#include <vorbis/ivorbisfile.h>
+#include "ivorbiscodec.h"
+#include "ivorbisfile.h"
 
 #ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
 #include <io.h>
@@ -69,7 +69,12 @@
       /* EOF */
       eof=1;
     } else if (ret < 0) {
-      /* error in the stream.  Not a problem, just reporting it in
+      if(ret==OV_EBADLINK){
+        fprintf(stderr,"Corrupt bitstream section! Exiting.\n");
+        exit(1);
+      }
+
+      /* some other error in the stream.  Not a problem, just reporting it in
 	 case we (the app) cares.  In this case, we don't. */
     } else {
       /* we don't bother dealing with sample rate changes, etc, but



More information about the commits mailing list