diff -up libsndfile-1.0.25/src/ms_adpcm.c.deb669ee libsndfile-1.0.25/src/ms_adpcm.c --- libsndfile-1.0.25/src/ms_adpcm.c.deb669ee 2021-07-23 13:20:56.365818063 +0200 +++ libsndfile-1.0.25/src/ms_adpcm.c 2021-07-23 13:21:08.241674184 +0200 @@ -140,6 +140,17 @@ wav_w64_msadpcm_init (SF_PRIVATE *psf, i if (psf->file.mode == SFM_WRITE) samplesperblock = 2 + 2 * (blockalign - 7 * psf->sf.channels) / psf->sf.channels ; + /* There's 7 samples per channel in the preamble of each block */ + if (samplesperblock < 7 * psf->sf.channels) + { psf_log_printf (psf, "*** Error samplesperblock (%d) should be >= %d.\n", samplesperblock, 7 * psf->sf.channels) ; + return SFE_INTERNAL ; + } ; + + if (2 * blockalign < samplesperblock * psf->sf.channels) + { psf_log_printf (psf, "*** Error blockalign (%d) should be >= %d.\n", blockalign, samplesperblock * psf->sf.channels / 2) ; + return SFE_INTERNAL ; + } ; + pmssize = sizeof (MSADPCM_PRIVATE) + blockalign + 3 * psf->sf.channels * samplesperblock ; if (! (psf->codec_data = calloc (1, pmssize)))