Merge pull request #117 from RealAstolfo/array-index-ub-change

moved array sanity check to before the array access
This commit is contained in:
Maneet Singh 2022-05-12 22:06:14 -07:00 committed by GitHub
commit a947dc4ad5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -402,7 +402,7 @@ struct DPCDHALImpl : DPCDHAL
if (caps.linkRateTable[0] != 0) if (caps.linkRateTable[0] != 0)
{ {
bIndexedLinkrateCapable = true; bIndexedLinkrateCapable = true;
for (int i = 0; caps.linkRateTable[i] && (i < NV_DPCD_SUPPORTED_LINK_RATES__SIZE); i++) for (int i = 0; (i < NV_DPCD_SUPPORTED_LINK_RATES__SIZE) && caps.linkRateTable[i]; i++)
{ {
if (linkRate < caps.linkRateTable[i]) if (linkRate < caps.linkRateTable[i])
linkRate = caps.linkRateTable[i]; linkRate = caps.linkRateTable[i];