← スキル一覧に戻る

detecting-unchecked-malloc
by waiwai24
⭐ 1🍴 0📅 2026年1月4日
SKILL.md
name: detecting-unchecked-malloc description: Detects unchecked return values of memory allocation functions like malloc, calloc, and realloc that can lead to null pointer dereferences. Use when analyzing memory allocation, error handling, or investigating null pointer risks.
Unchecked Return Value of Malloc Detection
Detection Workflow
- Identify allocation operations: Find all malloc() calls, locate calloc() calls, identify realloc() calls, map new/delete operations
- Trace return values: Follow allocation result, identify first dereference, check for NULL validation, assess error handling
- Check error handling: Verify NULL checks exist, assess error handling completeness, review fallback behavior, check for graceful degradation
- Assess impact: Can allocation fail? What happens on failure? Is crash possible? What's the security impact?
Key Patterns
- Unchecked malloc: malloc() return value not checked, direct use of malloc() result, no NULL check before dereference, assumption malloc never fails
- Unchecked calloc: calloc() return value not checked, direct use of calloc() result, no NULL check before dereference, assumption calloc never fails
- Unchecked realloc: realloc() return value not checked, direct assignment to original pointer, no NULL check before dereference, losing original pointer on failure
- Unchecked new (C++): new return value not checked, assuming new never throws, no exception handling, missing std::nothrow usage
Output Format
Report with: id, type, subtype, severity, confidence, location, vulnerability, allocation_call, allocation_type, allocation_size, null_check, first_dereference, exploitable, attack_scenario, impact, mitigation.
Severity Guidelines
- HIGH: Unchecked allocation in critical code
- MEDIUM: Unchecked allocation causing crashes
- LOW: Unchecked allocation with limited impact
See Also
patterns.md- Detailed detection patterns and exploitation scenariosexamples.md- Example analysis cases and code samplesreferences.md- CWE references and mitigation strategies
スコア
総合スコア
55/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
○言語
プログラミング言語が設定されている
0/5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です