Multiple choice technology security

Are there any memory issues in the following code? Please assume that variable inputsize has the correct size. int add_num_array(int inputsize, int num) { int newnum = malloc (inputsize * sizeof(int)); / 1 */ int i; for (i=0; i

  1. No vulnerabilities are present

  2. Line 1 should only use malloc(inputsize)

  3. Line 2 should be for (i=0; i<=n, i++)

  4. Line 1 should use calloc() instead of malloc()

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The code uses uninitialized memory from malloc(). Using += on uninitialized values reads garbage values. calloc() zero-initializes memory, which is the safe approach. Option B would allocate insufficient space, option C would cause an out-of-bounds access, and option A is incorrect - there is a vulnerability.