mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-19 00:04:04 +01:00
Added sanity check to MCA decoder, fixes some odd rips I've just encountered.
This commit is contained in:
parent
5aa501c329
commit
72f3e3555b
@ -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++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user