Wave parser bug in encoder
In the find_wav_chunk function (audio.c, line 120), we see:
static int find_wav_chunk(FILE *in, char *type, unsigned int *len) { unsigned char buf[8];
while(1)
{
if(fread(buf,1,8,in) < 8) /* Suck down a chunk specifier */
{
fprintf(stderr, _("Warning: Unexpected EOF in reading WAV header\n"));
return 0; /* EOF before reaching the appropriate chunk */
}
if(memcmp(buf, type, 4))
{
*len = READ_U32_LE(buf+4);
if(!seek_forward(in, *len))
return 0;
buf[4] = 0;
fprintf(stderr, _("Skipping chunk of type \"%s\", length %d\n"), buf, *len);
}
else
{
*len = READ_U32_LE(buf+4);
return 1;
}
}
}
I believe that the line:
if(!seek_forward(in, *len))
should probably read (note, code change is untested):
if(!seek_forward(in, *len + *len % 2))
This should properly seek to word boundaries as is specified by the RIFF specs (such that I could find).
Attached is a wave file that demonstrates this issue.