From 64350e068cb8488c1fec8e8c870dce936267e057 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Thu, 13 Sep 2007 23:01:16 +0000 Subject: Calculate number of samples correctly for any number of channels, so we don't overrun our destination array for > 2 channels. git-svn-id: https://svn.xiph.org/trunk/Tremor@13794 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- vorbisfile.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'vorbisfile.c') diff --git a/vorbisfile.c b/vorbisfile.c index 50b43f2..0c48f1f 100644 --- a/vorbisfile.c +++ b/vorbisfile.c @@ -1564,13 +1564,8 @@ long ov_read(OggVorbis_File *vf,char *buffer,int bytes_req,int *bitstream){ long channels=ov_info(vf,-1)->channels; - if(channels==1){ - if(samples>(bytes_req/2)) - samples=bytes_req/2; - }else{ - if(samples>(bytes_req/4)) - samples=bytes_req/4; - } + if(samples>(bytes_req/(2*channels))) + samples=bytes_req/(2*channels); for(i=0;i