Поделиться через


C6101

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 C6101: Returning uninitialized memory

A successful path through the function does not set the named _Out_ parameter. This message is generated based on SAL annotations that indicate that the function in question always succeeds. A function that doesn’t return a success/failure indication should set all of its _Out_ parameters because the analyzer assumes that the _Out_ parameter is uninitialized data before the function is called, and that the function will set the parameter so that it’s no longer uninitialized. If the function does indicate success/failure, then the _Out_ parameter doesn't have to be set in the case of failure, and you can detect and avoid the uninitialized location. In either case, the objective is to avoid the reading of an uninitialized location. If the function sometimes doesn’t touch an _Out_ parameter that’s subsequently used, then the parameter should be initialized before the function call and be marked with the _Inout_ annotation, or the more explicit _Pre_null_ or _Pre_satisfies_() when appropriate. "Partial success" can be handled with the _When_ annotation. For more information, see Using SAL Annotations to Reduce C/C++ Code Defects.