...
This example checks the value of num_blocks to make sure the subsequent multiplication operation cannot result in an integer overflow. The code also ensures that num_blocks is not equal to zero. (See MEM04-C. Do not perform zero-length allocations.)
Noncompliant Code Example (Range Checking)
...
The code also ensures that len is not equal to zero. (See MEM04-C. Do not perform zero-length allocations.)
Risk Assessment
...