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