CWE-395Use of NullPointerException Catch to Detect NULL Pointer Dereference

PUBLISHEDweakness record
released 2006-07-19 · last modified 2025-12-11

Metadata

CWE ID:
CWE-395
Abstraction:
Base
Structure:
Simple
Status:
Draft
Release Date:
2006-07-19
Latest Modification Date:
2025-12-11

Weakness Name

Use of NullPointerException Catch to Detect NULL Pointer Dereference

Description

Catching NullPointerException should not be used as an alternative to programmatic checks to prevent dereferencing a null pointer.

Programmers typically catch NullPointerException under three circumstances: Of these three circumstances, only the last is acceptable.

Common Consequences

Scope:
Availability
Impact:
DoS: Resource Consumption (CPU)

Related Weaknesses