Added sanity check to MCA decoder, fixes some odd rips I've just encountered.

This commit is contained in:
Christopher Snowhill 2017-01-09 09:24:44 -08:00
parent 5aa501c329
commit 72f3e3555b

View File

@ -11,7 +11,7 @@ VGMSTREAM * init_vgmstream_mca(STREAMFILE *streamFile) {
int channel_count;
int loop_flag;
int version;
size_t head_size, data_size;
size_t head_size, data_size, file_size;
off_t start_offset, coef_offset, coef_start, coef_shift;
int i, j;
int coef_spacing;
@ -78,6 +78,16 @@ VGMSTREAM * init_vgmstream_mca(STREAMFILE *streamFile) {
coef_offset = coef_start + coef_shift * 0x14;
}
/* sanity check */
file_size = get_streamfile_size(streamFile);
if (start_offset + data_size > file_size) {
if (head_size + data_size > file_size)
goto fail;
start_offset = file_size - data_size;
}
/* set up ADPCM coefs */
for (j = 0; j<vgmstream->channels; j++) {