Index: ivorbisfile_example.c =================================================================== --- ivorbisfile_example.c (revision 16191) +++ ivorbisfile_example.c (working copy) @@ -48,14 +48,16 @@ exit(1); } - /* Throw the comments plus a few lines about the bitstream we're - decoding */ - { - char **ptr=ov_comment(&vf,-1)->user_comments; - vorbis_info *vi=ov_info(&vf,-1); - while(*ptr){ - fprintf(stderr,"%s\n",*ptr); - ++ptr; + /* Throw the comments plus a few lines about the bitstream we're + decoding */ + { + char **ptr; + vorbis_info *vi=ov_info(&vf,-1); + if((ptr=ov_comment(&vf,-1)->user_comments) != NULL){ + while(*ptr){ + fprintf(stderr,"%s\n",*ptr); + ++ptr; + } } fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate); fprintf(stderr,"\nDecoded length: %ld samples\n", Index: info.c =================================================================== --- info.c (revision 16191) +++ info.c (working copy) @@ -100,6 +100,20 @@ } } +/* comment exceeded available memory, zero it and move on*/ +void vorbis_comment_zero(vorbis_comment *vc){ + if(vc){ + long i; + for(i=0;icomments;i++) + if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); + + if(vc->user_comments)_ogg_free(vc->user_comments); + vc->user_comments=NULL; + if(vc->comment_lengths)_ogg_free(vc->comment_lengths); + vc->comments=0; + } +} + /* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. They may be equal, but short will never ge greater than long */ int vorbis_info_blocksize(vorbis_info *vi,int zo){ @@ -193,21 +207,28 @@ vc->comments=oggpack_read(opb,32); if(vc->comments<0)goto err_out; vc->user_comments=(char **)_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments)); + if(vc->user_comments==NULL) goto alloc_error; vc->comment_lengths=(int *)_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths)); - + if(vc->comment_lengths==NULL) goto alloc_error; + for(i=0;icomments;i++){ int len=oggpack_read(opb,32); if(len<0)goto err_out; - vc->comment_lengths[i]=len; + vc->comment_lengths[i]=len; vc->user_comments[i]=(char *)_ogg_calloc(len+1,1); + if(vc->user_comments[i]==NULL) goto alloc_error; _v_readstring(opb,vc->user_comments[i],len); - } + } if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */ return(0); err_out: vorbis_comment_clear(vc); return(OV_EBADHEADER); + alloc_error: + vorbis_comment_zero(vc); + return 0; + } /* all of the real encoding details are here. The modes, books,