Detects incorrect use of free() including freeing non-heap memory, invalid pointers, and mismatched allocators. Use when analyzing memory deallocation, heap management, or investigating free() usage errors.
Scanned 2/12/2026
Install via CLI
openskills install majiayu000/claude-skill-registry---
name: detecting-incorrect-free
description: Detects incorrect use of free() including freeing non-heap memory, invalid pointers, and mismatched allocators. Use when analyzing memory deallocation, heap management, or investigating free() usage errors.
---
# Incorrect Use of Free Detection
## Detection Workflow
1. **Identify free operations**: Find all free() calls, locate delete/delete[] calls, map deallocation points, note pointers being freed
2. **Trace pointer origins**: Find where pointers originate, identify allocation method, track pointer assignments, assess pointer validity
3. **Analyze memory type**: Verify pointer points to heap memory, check for stack variables, identify static/global variables, assess pointer validity
4. **Assess impact**: Can incorrect free cause crash? Can it cause heap corruption? What's the security impact? Is it exploitable?
## Key Patterns
- Freeing non-heap memory: free() on stack variables, free() on static/global variables, free() on string literals, free() on automatic storage
- Freeing invalid pointers: free() on NULL pointer, free() on already-freed memory, free() on uninitialized pointers, free() on middle of allocations
- Mismatched allocators: free() on new-allocated memory, delete on malloc-allocated memory, cross-allocator deallocation, mixed C/C++ memory management
- Double free patterns: multiple free() on same pointer, free() in multiple code paths, free() in error handling, free() in cleanup functions
## Output Format
Report with: id, type, subtype, severity, confidence, location, vulnerability, freed_pointer, pointer_type, allocation_type, free_operation, exploitable, attack_scenario, impact, mitigation.
## Severity Guidelines
- **HIGH**: Incorrect free causing heap corruption
- **MEDIUM**: Incorrect free causing crashes
- **LOW**: Incorrect free with limited impact
## See Also
- `patterns.md` - Detailed detection patterns and exploitation scenarios
- `examples.md` - Example analysis cases and code samples
- `references.md` - CWE references and mitigation strategiesNo comments yet. Be the first to comment!
Designs system architecture, component specifications, and technical integration strategy. Use when: designing solutions, system architecture, technology stack, or integration approaches.
Generate a comprehensive VC investment assessment report for a company
Manage Globalize translation resources using the CLI. Use this skill when the user asks to create a translation project, add or remove languages, connect a GitHub or GitLab repository, manage glossaries or style guides, invite team members, manage API keys, or perform any Globalize platform operation. Also use when the user mentions managing translations, translation workflow, or wants to "set up translations for this repo." This skill assumes the CLI is already installed and authenticated — ...
Develop and operate a local Paperclip instance — start and stop servers, pull updates from master, run builds and tests, manage worktrees, back up databases, and diagnose problems. Use whenever you need to work on the Paperclip codebase itself or keep a running instance healthy.
Guide for creating, updating, and deprecating hybrid cloud RPC services in Sentry. Use when asked to "add RPC method", "create RPC service", "hybrid cloud service", "new RPC model", "deprecate RPC method", "remove RPC endpoint", "cross-silo service", "cell RPC", or "control silo service". Covers service scaffolding, method signatures, RPC models, cell resolvers, testing, and safe deprecation workflows.