Fix memory leak in caf_read_header()

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30375

Credit to OSS-Fuzz.
This commit is contained in:
evpobr 2021-02-08 09:18:19 +05:00
parent 89bed47c45
commit dca6f8abbb
2 changed files with 6 additions and 0 deletions

View File

@ -21,5 +21,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
* Typo in `docs/index.md`.
* Memory leak in `caf_read_header`(), credit to OSS-Fuzz ([issue 30375](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30375)).
[Unreleased]: https://github.com/libsndfile/libsndfile/compare/1.0.31...HEAD

View File

@ -416,6 +416,11 @@ caf_read_header (SF_PRIVATE *psf)
return SFE_CAF_BAD_PEAK ;
} ;
if (psf->peak_info)
{ psf_log_printf (psf, "*** Found existing peak info, using last one.\n") ;
free (psf->peak_info) ;
psf->peak_info = NULL ;
} ;
if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL)
return SFE_MALLOC_FAILED ;