Validate max channels on allocation

This commit is contained in:
bnnm 2018-02-25 12:17:51 +01:00
parent 4331fb7685
commit 3c1d4ee825

View File

@ -627,7 +627,9 @@ VGMSTREAM * allocate_vgmstream(int channel_count, int looped) {
VGMSTREAMCHANNEL * start_channels; VGMSTREAMCHANNEL * start_channels;
VGMSTREAMCHANNEL * loop_channels; VGMSTREAMCHANNEL * loop_channels;
if (channel_count <= 0) return NULL; /* up to ~16 aren't too rare for multilayered files, more is probably a bug */
if (channel_count <= 0 || channel_count > 64)
return NULL;
vgmstream = calloc(1,sizeof(VGMSTREAM)); vgmstream = calloc(1,sizeof(VGMSTREAM));
if (!vgmstream) return NULL; if (!vgmstream) return NULL;