Id: arrayIndexOutOfBoundsCond
CWE: 788
Either the condition 'OutputChannels[i]>Aac_OutputChannelPosition_Size' is redundant or the array 'Aac_ChannelMode[43]' is accessed at index 43, which is out of bounds.
The issue is that Aac_OutputChannelPosition_Size is 43 and Aac_ChannelMode has 43 elements. Since an array starts with 0, the max we can access in Aac_ChannelMode is 42. So we change >Aac_OutputChannelPosition_Size to >=Aac_OutputChannelPosition_Size to prevent accessing Aac_ChannelMode[43].
As mentioned in https://github.com/MediaArea/MediaInfoLib/issues/2105#issuecomment-2381399096, this is one of the issues found with Visual Studio Code Analysis and also Cppcheck.
Visual Studio:
Cppcheck:
https://github.com/MediaArea/MediaInfoLib/blob/00d96580cfaff7f189af13d6ec6cf8f7d8b3a72d/Source/MediaInfo/Audio/File_Aac_Main.cpp#L498-L501
The issue is that
Aac_OutputChannelPosition_Size
is 43 andAac_ChannelMode
has 43 elements. Since an array starts with0
, the max we can access inAac_ChannelMode
is 42. So we change>Aac_OutputChannelPosition_Size
to>=Aac_OutputChannelPosition_Size
to prevent accessingAac_ChannelMode[43]
.