From 23361c7ff83031309e9b98f1a309d07a4c73a171 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 24 Jul 2009 01:51:10 +0000 Subject: [PATCH] Fix for Trac #1573. This is two bugs. The first is that vorbisfile_example.c ignores an error code and plows ahead blindly if libvorbisfile reports the current bitstream section is bad (OV_EBADLINK). The second is that retrying after the error crashes libvorbisfile due to the unitialized state. svn path=/trunk/vorbis/; revision=16328 --- examples/vorbisfile_example.c | 7 ++++++- lib/block.c | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/vorbisfile_example.c b/examples/vorbisfile_example.c index 728a9c5..4c27fa4 100644 --- a/examples/vorbisfile_example.c +++ b/examples/vorbisfile_example.c @@ -70,7 +70,12 @@ int main(){ /* 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 diff --git a/lib/block.c b/lib/block.c index 3bf8fba..693d40a 100644 --- a/lib/block.c +++ b/lib/block.c @@ -232,9 +232,10 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ v->analysisp=1; }else{ /* finish the codebooks */ - if(!ci->fullbooks){ + if(!ci->fullbooks) ci->fullbooks=_ogg_calloc(ci->books,sizeof(*ci->fullbooks)); - for(i=0;ibooks;i++){ + for(i=0;ibooks;i++){ + if(ci->book_param[i]!=NULL){ if(vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i])) return -1; /* decode codebooks are now standalone after init */ -- 2.7.4