Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Postcondition for null pointer 'variable' requires it to be non-null (lifetime.1)
Remarks
Dereferencing a null pointer is a frequent problem in C and C++. We have several checks to deal with such problems. See this blog post for a comparison. When the analysis engine sees a null pointer returned from a function that has a contract forbidding such an operation, it will emit a C26824
warning. You can also enable C26825 for a stricter analysis. This check only works on functions annotated using SAL annotations.
Example
void postcondition_conditional(bool b, _When_(b == true, _Outptr_) int** p) {
if (b == true)
*p = nullptr; // C26824 warning
}
To solve this warning, make sure there's no null pointer returned from the annotated function. Or, change the annotations to reflect the behavior of the function.