mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
src/sndfile.c : Fix calculation of internal value psf->read_current when attempting to read past end of audio data.
This commit is contained in:
parent
141884b65c
commit
8ff611b86e
@ -1,3 +1,9 @@
|
||||
2007-11-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/sndfile.c
|
||||
Fix calculation of internal value psf->read_current when attempting to read
|
||||
past end of audio data.
|
||||
|
||||
2007-11-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* configure.ac src/Makefile.am src/create_symbols_file.py
|
||||
|
@ -1345,15 +1345,15 @@ sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t len)
|
||||
|
||||
count = psf->read_short (psf, ptr, len) ;
|
||||
|
||||
if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
|
||||
if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
else
|
||||
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
|
||||
extra = len - count ;
|
||||
psf_memset (ptr + count, 0, extra * sizeof (short)) ;
|
||||
psf->read_current = psf->sf.frames ;
|
||||
} ;
|
||||
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
|
||||
psf->last_op = SFM_READ ;
|
||||
|
||||
if (psf->read_current > psf->sf.frames)
|
||||
@ -1392,15 +1392,15 @@ sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames)
|
||||
|
||||
count = psf->read_short (psf, ptr, frames * psf->sf.channels) ;
|
||||
|
||||
if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
|
||||
if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
else
|
||||
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
|
||||
extra = frames * psf->sf.channels - count ;
|
||||
psf_memset (ptr + count, 0, extra * sizeof (short)) ;
|
||||
psf->read_current = psf->sf.frames ;
|
||||
} ;
|
||||
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
|
||||
psf->last_op = SFM_READ ;
|
||||
|
||||
if (psf->read_current > psf->sf.frames)
|
||||
@ -1447,15 +1447,15 @@ sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t len)
|
||||
|
||||
count = psf->read_int (psf, ptr, len) ;
|
||||
|
||||
if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
|
||||
if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
else
|
||||
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
|
||||
extra = len - count ;
|
||||
psf_memset (ptr + count, 0, extra * sizeof (int)) ;
|
||||
psf->read_current = psf->sf.frames ;
|
||||
} ;
|
||||
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
|
||||
psf->last_op = SFM_READ ;
|
||||
|
||||
if (psf->read_current > psf->sf.frames)
|
||||
@ -1494,15 +1494,15 @@ sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames)
|
||||
|
||||
count = psf->read_int (psf, ptr, frames * psf->sf.channels) ;
|
||||
|
||||
if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
|
||||
if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
else
|
||||
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
|
||||
extra = frames * psf->sf.channels - count ;
|
||||
psf_memset (ptr + count, 0, extra * sizeof (int)) ;
|
||||
psf->read_current = psf->sf.frames ;
|
||||
} ;
|
||||
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
|
||||
psf->last_op = SFM_READ ;
|
||||
|
||||
if (psf->read_current > psf->sf.frames)
|
||||
@ -1549,15 +1549,15 @@ sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t len)
|
||||
|
||||
count = psf->read_float (psf, ptr, len) ;
|
||||
|
||||
if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
|
||||
if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
else
|
||||
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
|
||||
extra = len - count ;
|
||||
psf_memset (ptr + count, 0, extra * sizeof (float)) ;
|
||||
psf->read_current = psf->sf.frames ;
|
||||
} ;
|
||||
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
|
||||
psf->last_op = SFM_READ ;
|
||||
|
||||
if (psf->read_current > psf->sf.frames)
|
||||
@ -1596,15 +1596,15 @@ sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames)
|
||||
|
||||
count = psf->read_float (psf, ptr, frames * psf->sf.channels) ;
|
||||
|
||||
if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
|
||||
if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
else
|
||||
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
|
||||
extra = frames * psf->sf.channels - count ;
|
||||
psf_memset (ptr + count, 0, extra * sizeof (float)) ;
|
||||
psf->read_current = psf->sf.frames ;
|
||||
} ;
|
||||
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
|
||||
psf->last_op = SFM_READ ;
|
||||
|
||||
if (psf->read_current > psf->sf.frames)
|
||||
@ -1651,15 +1651,15 @@ sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t len)
|
||||
|
||||
count = psf->read_double (psf, ptr, len) ;
|
||||
|
||||
if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
|
||||
if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
else
|
||||
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
|
||||
extra = len - count ;
|
||||
psf_memset (ptr + count, 0, extra * sizeof (double)) ;
|
||||
psf->read_current = psf->sf.frames ;
|
||||
} ;
|
||||
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
|
||||
psf->last_op = SFM_READ ;
|
||||
|
||||
if (psf->read_current > psf->sf.frames)
|
||||
@ -1698,15 +1698,15 @@ sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames)
|
||||
|
||||
count = psf->read_double (psf, ptr, frames * psf->sf.channels) ;
|
||||
|
||||
if (psf->read_current + count / psf->sf.channels > psf->sf.frames)
|
||||
if (psf->read_current + count / psf->sf.channels <= psf->sf.frames)
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
else
|
||||
{ count = (psf->sf.frames - psf->read_current) * psf->sf.channels ;
|
||||
extra = frames * psf->sf.channels - count ;
|
||||
psf_memset (ptr + count, 0, extra * sizeof (double)) ;
|
||||
psf->read_current = psf->sf.frames ;
|
||||
} ;
|
||||
|
||||
psf->read_current += count / psf->sf.channels ;
|
||||
|
||||
psf->last_op = SFM_READ ;
|
||||
|
||||
if (psf->read_current > psf->sf.frames)
|
||||
|
Loading…
Reference in New Issue
Block a user