CWE一覧に戻る
CWE-580

clone()メソッド super.clone()なし

clone() Method Without super.clone()
脆弱性 レビュー中
JA

この製品には、新しいオブジェクトを取得するために super.clone() を呼び出さない clone() メソッドがあります。

clone()のすべての実装は、super.clone()を呼び出して新しいオブジェクトを取得する必要があります。クラスがこの規約に従わない場合、サブクラスのclone()メソッドは間違った型のオブジェクトを返します。

EN

The product contains a clone() method that does not call super.clone() to obtain the new object.

All implementations of clone() should obtain the new object by calling super.clone(). If a class does not follow this convention, a subclass's clone() method will return an object of the wrong type.

Scope: Integrity, Other / Impact: Unexpected State; Quality Degradation
Call super.clone() within your clone() method, when obtaining a new object.
In some cases, you can eliminate the clone method altogether and use copy constructors.
MITRE公式ページ — CWE-580