CWE-395

Use of NullPointerException Catch to Detect NULL Pointer Dereference

Medium

Description

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

Potential Impact

How to Fix

Architecture and Design

Do not extensively rely on catching exceptions (especially for validating user input) to handle errors. Handling exceptions can decrease the performance of an application.

Detection Methods

Related Weaknesses

References

View on MITRE CWE Database →

Need Help Fixing This Vulnerability?

Our security experts can help you identify and remediate CWE-395 vulnerabilities in your codebase.

Get Security Assessment