הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
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 a[MAX];
a[MAX] = '\0'; // this writes one element past the end of the buffer
}
To correct the warning, use the following code which accounts for the fact that array indexes are zero-based. Thus MAX - 1
is the last element in the buffer:
#define MAX 25
void f ( )
{
char a[MAX];
a[MAX-1] = '\0';
}