JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++
Binaries


LANG.STRUCT.RPL : ローカル変数へのポインタ戻し

要旨

関数が、ローカル変数を参照するポインタを返り値としています。

プロパティ

クラス名 Return Pointer to Local
日本語クラス名 ローカル変数へのポインタ戻し
クラス分類 セキュリティ (security)
ニーモニック LANG.STRUCT.RPL
カテゴリー
MisraC2025 MisraC2025:18.6 The address of an object with automatic or thread-local storage shall not be copied to another object that persists after the first object has ceased to exist
MisraC2023 MisraC2023:18.6 The address of an object with automatic or thread-local storage shall not be copied to another object that persists after the first object has ceased to exist
Misra2012 Misra2012:18.6 The address of an object with automatic or thread-local storage shall not be copied to another object that persists after the first object has ceased to exist
AUTOSARC++14 AUTOSARC++14:M7-5-1 A function shall not return a reference or a pointer to an automatic variable (including parameters), defined within the function.
MisraC++2008 MisraC++2008:7-5-1 A function shall not return a reference or a pointer to an automatic variable (including parameters), defined within the function.
MisraC++2023 MisraC++2023:6.8.2 A function must not return a reference or a pointer to a local variable with automatic storage duration
CWE CWE:562 Return of Stack Variable Address
TS17961 TS17961:5.14-nullref Dereferencing an out-of-domain pointer
CERT-C CERT-C:DCL30-C Declare objects with appropriate storage durations
CERT-CPP CERT-CPP:EXP53-CPP Do not read uninitialized memory
JSF++ JSF++:70.1 An object shall not be improperly used before its lifetime begins or after its lifetime ends.
  JSF++:111 A function shall not return a pointer or reference to a non-static local object.
  JSF++:173 The address of an object with automatic storage shall not be assigned to an object which persists after the object has ceased to exist.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Return Pointer to Local"

int * lang_struct_rpl(void){
    int j = 7;
    return &j; /* 'Return Pointer To Local' warning issued here */
}

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。

 

To report problems with this documentation, please visit https://support.codesecure.com/.