diff --git a/src/test_streams/main.c b/src/test_streams/main.c index 84044808..0b9f4978 100644 --- a/src/test_streams/main.c +++ b/src/test_streams/main.c @@ -612,7 +612,8 @@ foo: static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsigned channels, unsigned bytes_per_sample, unsigned samples) { - const unsigned size = channels * bytes_per_sample * samples; + const unsigned true_size = channels * bytes_per_sample * samples; + const unsigned padded_size = (true_size + 1) & (~1u); FILE *f; unsigned i; @@ -620,7 +621,7 @@ static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsig return false; if(fwrite("RIFF", 1, 4, f) < 4) goto foo; - if(!write_little_endian_uint32(f, size + 36)) + if(!write_little_endian_uint32(f, padded_size + 36)) goto foo; if(fwrite("WAVEfmt \020\000\000\000\001\000", 1, 14, f) < 14) goto foo; @@ -636,12 +637,15 @@ static FLAC__bool generate_wav(const char *filename, unsigned sample_rate, unsig goto foo; if(fwrite("data", 1, 4, f) < 4) goto foo; - if(!write_little_endian_uint32(f, size)) + if(!write_little_endian_uint32(f, true_size)) goto foo; - for(i = 0; i < size; i++) + for(i = 0; i < true_size; i++) if(fputc(i, f) == EOF) goto foo; + for( ; i < padded_size; i++) + if(fputc(0, f) == EOF) + goto foo; fclose(f); return true;