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 |
A use of realloc(), which is not guaranteed to preserve alignment in all cases.
| クラス名 | Use of realloc | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | reallocの使用 | |||||||||||||||||||||||||||||||||||||||
| クラス分類 | セキュリティ (security) | |||||||||||||||||||||||||||||||||||||||
| ニーモニック | BADFUNC.REALLOC | |||||||||||||||||||||||||||||||||||||||
| カテゴリー |
|
|||||||||||||||||||||||||||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
|||||||||||||||||||||||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Use of realloc" |
#include <stdlib.h>
typedef struct my_128b_aligned_type {
int i;
char c;
/* ... */
} my_aligned_t; /* user-defined type that must be aligned to a 128-byte boundary */
my_aligned_t * reallocate_realloc(my_aligned_t *obj){
return realloc(obj, sizeof(my_aligned_t)); /* 'Use of realloc' warning issued here:
* realloc() does not preserve the alignment properties required for my_aligned_type
*/
}
my_aligned_t * reallocate_posix_memalign(my_aligned_t *obj){
void *rv = obj;
if (posix_memalign(&rv, 128, sizeof(my_aligned_t))){ /* ok: posix_memalign() lets us specify the required alignment */
return NULL;
}
if (obj){
free(obj); /* must explicitly free previous object to avoid memory leaks< */
}
return rv;
}
このクラスは一般テンプレート設定ファイルで BAD_FUNCTION_* ルールセットによって実装されています。
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。
To report problems with this documentation, please visit https://support.codesecure.com/.