...
This compliant solution range-checks both the i
and j
variables before converting to the resulting integer type. Since Because both values are out of the valid range for a short
, this code will always throw an ArithmeticException
.
...
Perform range checks on both i
and j
variables before proceeding with the conversions. Since Because both values are out of the valid range for a short
, this code will always throw an ArithmeticException
.
...
INT31-C. Ensure that integer conversions do not result in lost or misinterpreted data | ||||
| FLP34-C. Ensure that floating point conversions are within range of the new type | |||
INT31-CPP. Ensure that integer conversions do not result in lost or misinterpreted data | ||||
| FLP34-CPP. Ensure that floating point conversions are within range of the new type | |||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6560152de8f78bf8-fcdafd43-4a824c3e-b1e58590-d1bbcda8349e6c7be1740a11"><ac:plain-text-body><![CDATA[ | [ISO/IEC TR 24772:2010 | http://www.aitcnet.org/isai/] | "Numeric Conversion Errors [FLC]" | ]]></ac:plain-text-body></ac:structured-macro> |
CWE ID 681, "Incorrect Conversion between Numeric Types" | ||||
| CWE ID 197, "Numeric Truncation Error" |
...