@@ -53,7 +53,7 @@ extern int debug_logging_mode;
5353
5454int ParseRiffHeaderConfig (FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config )
5555{
56- int is_rf64 = !strncmp (fourcc , "RF64" , 4 ), got_ds64 = 0 ;
56+ int is_rf64 = !strncmp (fourcc , "RF64" , 4 ), got_ds64 = 0 , format_chunk = 0 ;
5757 int64_t total_samples = 0 , infilesize ;
5858 RiffChunkHeader riff_chunk_header ;
5959 ChunkHeader chunk_header ;
@@ -140,6 +140,11 @@ int ParseRiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, Wavpack
140140 else if (!strncmp (chunk_header .ckID , "fmt " , 4 )) { // if it's the format chunk, we want to get some info out of there and
141141 int supported = TRUE, format ; // make sure it's a .wav file we can handle
142142
143+ if (format_chunk ++ ) {
144+ error_line ("%s is not a valid .WAV file!" , infilename );
145+ return WAVPACK_SOFT_ERROR ;
146+ }
147+
143148 if (chunk_header .ckSize < 16 || chunk_header .ckSize > sizeof (WaveHeader ) ||
144149 !DoReadFile (infile , & WaveHeader , chunk_header .ckSize , & bcount ) ||
145150 bcount != chunk_header .ckSize ) {
0 commit comments