<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

    Missing Check for Null Parameter

    ABSTRACT

    函數必須檢查其參數是否為 null,當前函數違反了這一規定。

    EXPLANATION

    Java 標準指出,實現 Object.equals()Comparable.compareTo()Comparator.compare() 方法時,如果其參數為 null,則必須返回一個指定值。不遵守該規定可能會導致發生意外的行為。

    例 1:以下代碼實現了 equals() 方法,但沒有檢查參數是否為 null。


    public boolean equals(Object object)
    {
    return (toString().equals(object.toString()));
    }

    REFERENCES

    [1] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 398


    Copyright 2013 Fortify Software - All rights reserved.
    (Generated from version 2013.1.1.0008 of the Fortify Secure Coding Rulepacks)
    desc.controlflow.java.missing_check_for_null_parameter

    97av