Commit ff67c8b5 authored by Timothy B. Terriberry's avatar Timothy B. Terriberry

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.


git-svn-id: https://svn.xiph.org/trunk/Tremor@17526 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent 28854b56
......@@ -161,14 +161,16 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
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 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){
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){
......
......@@ -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 @@ 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment