Warning C6386

Buffer overrun: accessing 'buffer name', the writable size is 'size1' bytes, but 'size2' bytes may be written: Lines: x, y

Remarks

This warning indicates that the writable extent of the specified buffer might be smaller than the index used to write to it. This defect can cause buffer overrun.

Code analysis name: WRITE_OVERRUN

Example

The following code generates both this warning and C6201:

#define MAX 25

void f ( )
{
  char ar[MAX];
  // code ...
  ar[MAX] = '\0';
}

To correct both warnings, use the following code:

#define MAX 25

void f ( )
{
   char a[MAX];
   // code ...
   a[MAX - 1] = '\0';
}

See also

C6201