Partilhar via


C6054

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

warning C6054: string <variable> may not be zero-terminated

This warning indicates that a function that requires zero-terminated string was passed a non-zero terminated string. A function that expects a zero-terminated string will go beyond the end of the buffer to look for the zero. This defect might cause an exploitable buffer overrun error or crash. The program should make sure that the string ends with a zero.

Example

The following code generates this warning:

  
#include <sal.h>  
  
void func( _In_z_ wchar_t* wszStr );  
  
void g ( )  
{  
    wchar_t wcArray[200];  
    func(wcArray); // Warning C6054  
}  

To correct this warning, null-terminate wcArray before calling function func() as shown in the following sample code:

  
#include <sal.h>  
  
void func( _In_z_ wchar_t* wszStr );  
  
void g( )  
{  
    wchar_t wcArray[200];   
    wcArray[0]= '\0';  
    func(wcArray);  
}  

See Also

C6053
Annotation Overview
NullTerminated