...
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-AC. Do not perform zero length allocations).
...
The code also ensures that len is not equal to zero (see MEM04-AC. Do not perform zero length allocations).
...