Show: Delphi
C++
Display Preferences
ANR - Accessing Null Reference
From RAD Studio
Go Up to C++ Audits
This Audit Is Temporary Disabled - Do not delete this topic
Description
ANR detects cases where evaluation of a field reference expression will result in an exception being thrown. ANR is reported whenever a non-static field of an object or array is accessed and the left operand of the . or -> (member access) operator has the null value.
Depending on the detected problem, the ANR audit can generate two messages:
- Call of method '%s' is via null pointer '%s'
- Access to field '%s' is via null pointer '%s'
Incorrect:
void PrintMessage(Message* msg) { if (msg) { msg->Print(); } else { printf("Message %s is null",msg->ToString()); } }
Correct:
void PrintMessage(Message* msg) { if (msg) { msg->Print(); } else { printf("Message is null"); } }