Q: Given the following code slice:
```
1 static void
2 fillpattern (int type, unsigned char *r, size_t size)
4   size_t i;
11   for (i = 3; i < size / 2; i *= 2)
12       memcpy (r + i, r, i);```
which has a CWE-787 vulnerability at line:
```
12     memcpy (r + i, r, i);
```
Please analyze the root cause of the vulnerability.