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 possibly null pointer 'variable' requires it to be non-null (lifetime.1)
Remarks
Dereferencing a null pointer is a frequent problem in C and C++. The static analysis engine includes several checks to deal with such problems. For a comparison, see this blog post. When the analysis engine determines that a function might produce a null pointer despite a SAL postcondition that requires a non-null value, it emits warning C26825. A common cause is assigning a parameter or return value without a non-null guarantee to an _Outptr_ output parameter. You can enable C26824 to report values known to be null. This check only works on functions annotated using SAL annotations.
Example
void postcondition_conditional(int *q, _Outptr_ int** p) {
*p = q; // C26825 warning
}
To resolve this warning, ensure the annotated function returns a non-null value or outputs a non-null value on every path where the contract applies. Or, change the annotations to reflect the behavior of the function.