Skip to content
Back to skills

Detecting Incorrect Free

ASecurity

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.

  • 666 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 8, 2026
businessc++security

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill detecting-incorrect-free --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Detecting Incorrect Free?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Detecting Incorrect Free
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-detecting-incorrect-free/badge)](https://www.skillsdirectory.com/skills/majiayu000-detecting-incorrect-free)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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 strategies

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.