

**Patch 2:**

The second patch uses a ternary operator to determine the number of bytes to copy, ensuring that the value is always non-negative. This avoids the out-of-bounds access.

