957
Notes
Relationship
Usually primary, but can be resultant from issues such as behavioral change or API abuse. This
can produce resultant vulnerabilities.
Taxonomy Mappings
Mapped Taxonomy Name Node ID Fit Mapped Node Name
PLOVER Unexpected Status Code or Return
Value
Software Fault Patterns SFP4 Unchecked Status Condition
SEI CERT Perl Coding
Standard
EXP00-
PL
Imprecise Do not return undef
CWE-395: Use of NullPointerException Catch to Detect NULL Pointer
Dereference
Weakness ID : 395
Structure : Simple
Abstraction : Base
Description
Catching NullPointerException should not be used as an alternative to programmatic checks to
prevent dereferencing a null pointer.
Extended Description
Programmers typically catch NullPointerException under three circumstances:
• The program contains a null pointer dereference. Catching the resulting exception was easier
than fixing the underlying problem.
• The program explicitly throws a NullPointerException to signal an error condition.
• The code is part of a test harness that supplies unexpected input to the classes under test.
Of these three circumstances, only the last is acceptable.
Relationships
The table(s) below shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOr and give insight to
similar items that may exist at higher and lower levels of abstraction. In addition, relationships such
as PeerOf and CanAlsoBe are defined to show similar weaknesses that may want to be explored.
Relevant to the view "Research Concepts" (CWE-1000)
Nature Type ID Name Page
ChildOf 755 Improper Handling of Exceptional Conditions 1576
ChildOf 705 Incorrect Control Flow Scoping 1542
Relevant to the view "Software Development" (CWE-699)
Nature Type ID Name Page
MemberOf 389 Error Conditions, Return Values, Status Codes 2322
Applicable Platforms
Language : Java (Prevalence = Undetermined)
Common Consequences
CWE Version 4.14
CWE-395: Use of NullPointerException Catch to Detect NULL Pointer Dereference
CWE-395: Use of NullPointerException Catch to Detect NULL Pointer Dereference