Q: Given the following code slice:
```
1 get_sos (j_decompress_ptr cinfo)
5   int i, ci, n, c, cc;
21   cinfo->comps_in_scan = n;
25   for (i = 0; i < cinfo->num_components; i++)
26       cinfo->cur_comp_info[i] = NULL; // cinfo->cur_comp_info has length MAX_COMPS_IN_SCAN```
which has a CWE-787 vulnerability at line:
```
26     cinfo->cur_comp_info[i] = NULL; // cinfo->cur_comp_info has length MAX_COMPS_IN_SCAN
```
Please analyze the root cause of the vulnerability.