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 |
初期化フェーズ以外で動的なメモリ割り当てを行いました。
このチェックの目的は、関数内の初期化フェーズで直接もしくは DYN_INIT_FUNCTIONS パラメータで設定された関数 f() から間接的にメモリ割り当てが行われていることを確認することです。
| クラス名 | Dynamic Allocation After Initialization | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | 初期化後の動的な割り当て | ||||||||||||||||||||||||||||||||||||||||||
| クラス分類 | スタイル (style) | ||||||||||||||||||||||||||||||||||||||||||
| ニーモニック | ALLOC.POSTINIT | ||||||||||||||||||||||||||||||||||||||||||
| カテゴリー |
|
||||||||||||||||||||||||||||||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
||||||||||||||||||||||||||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Dynamic Allocation After Initialization" |
#include <stdlib.h> char * disk_buff; char * network_buff; /* With factory settings, function name 'dyn_init' matches a * DYN_INIT_FUNCTIONS rule, so this function can directly or * transitively call allocator functions without triggering a 'Dynamic * Allocation After Initialization' warning */ void dyn_init(void){ disk_buff = malloc(1024); network_buff = malloc(2048); } int main(int argc, char *argv[]){ char *r; char rv = 0; /* starting process - do all dynamic allocation now */ dyn_init(); /* no more dynamic allocation from this point on */ /* ... */ r = malloc(5); /* 'Dynamic Allocation After Initialization' warning issued here */ /* ... */ if (r){ rv = 1; free(r); } return rv; }
このクラスを引き起こす関数は以下となります。
プログラムエントリーポイントから到達可能なコードのみこのクラスのワーニングを引き起こすことが可能です。 CodeSonar は設定ファイルの PROGRAM_ENTRY_POINTS パラメータに設定されている関数をプログラムエントリーポイントとみなします。 このパラメータは main() と init() がデフォルトで設定されています。
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。
To report problems with this documentation, please visit https://support.codesecure.com/.