Commit 32685de7 authored by Josh Coalson's avatar Josh Coalson
Browse files

fix bug when skipping data

parent fa697a98
......@@ -223,15 +223,13 @@ int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, cons
bps = x;
is_unsigned_samples = (x == 8);
bytes_per_wide_sample = channels * (bps >> 3);
/* skip any extra data in the fmt sub-chunk */
data_bytes -= 16;
if(data_bytes > 0) {
unsigned left, need;
for(left = data_bytes; left > 0; ) { /*@@@ WATCHOUT: 4GB limit */
for(left = data_bytes; left > 0; ) {
need = min(left, CHUNK_OF_SAMPLES);
if(fread(ucbuffer, 1, bytes_per_wide_sample * need, infile) < need) {
if(fread(ucbuffer, 1, need, infile) < need) {
fprintf(stderr, "%s: ERROR during read while skipping samples\n", encoder_wrapper.inbasefilename);
goto wav_abort_;
}
......@@ -269,7 +267,7 @@ int flac__encode_wav(FILE *infile, long infilesize, const char *infilename, cons
unsigned left, need;
for(left = (unsigned)skip; left > 0; ) { /*@@@ WATCHOUT: 4GB limit */
need = min(left, CHUNK_OF_SAMPLES);
if(fread(ucbuffer, 1, bytes_per_wide_sample * need, infile) < need) {
if(fread(ucbuffer, bytes_per_wide_sample, need, infile) < need) {
fprintf(stderr, "%s: ERROR during read while skipping samples\n", encoder_wrapper.inbasefilename);
goto wav_abort_;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment