memory-safety-patterns
Apply Memory Safety Patterns
Memory bugs cause crashes, leaks, and security defects in systems software. This skill gives practical patterns for safer resource ownership across C, C++, and Rust.
Install with my Agent
Copy this request to your Agent. It includes the canonical Skill page and manifest.
Review the Skillstore skill "memory-safety-patterns" from https://skillstore.io/skills/wshobson-memory-safety-patterns.md and its manifest at https://skillstore.io/api/skills/wshobson-memory-safety-patterns/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.Your Agent should still show its plan and request any confirmation required by the security policy.
Agent-readable resources
Use these links when an AI agent, crawler, or script needs clean context instead of reading the full page.
Test it
Using "memory-safety-patterns". I need to manage a file handle in C++ without leaks.
Expected outcome:
- Use a RAII wrapper that owns the file handle and closes it in the destructor.
- Delete copy operations, allow move operations, and keep ownership transfer explicit.
- Add error handling at construction so invalid resources cannot escape.
Using "memory-safety-patterns". My Rust service shares counters across worker threads.
Expected outcome:
- Use Arc for shared ownership across threads.
- Use atomics for simple counters and Mutex or RwLock for compound state.
- Join worker handles and handle lock errors deliberately.
Using "memory-safety-patterns". I am reviewing a C API that allocates several resources.
Expected outcome:
- Define clear create and destroy functions for every owned resource.
- Use one cleanup path that frees resources in reverse allocation order.
- Document which function owns each pointer after every call.
Security Audit
SafeAll static findings are false positives from Markdown examples, code fences, public reference links, or illustrative C, C++, and Rust snippets. No prompt injection, hidden automation, data exfiltration intent, or malicious semantic behavior was found in SKILL.md.
Risk Factors
โ๏ธ External commands (23)
๐ Network access (3)
๐ Filesystem access (1)
Share & cite this report
Share the versioned assessment report, neutral badge, embed card, and citations. Skillstore reports evidence without deciding whether this Skill is safe.
Copy report link
https://skillstore.io/skills/wshobson-memory-safety-patterns/audits/7?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown badge
[](https://skillstore.io/skills/wshobson-memory-safety-patterns?utm_source=security_passport_badge)HTML badge
<a href="https://skillstore.io/skills/wshobson-memory-safety-patterns?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/wshobson-memory-safety-patterns/security.svg" alt="Skillstore security assessment" loading="lazy"></a>Embed card
<iframe src="https://skillstore.io/embed/skills/wshobson-memory-safety-patterns.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>Academic citations (APA ยท BibTeX ยท CFF)
APA citation
wshobson. (2026). memory-safety-patterns security audit report (audit version 7) [Author version unspecified]. Skillstore. https://skillstore.io/skills/wshobson-memory-safety-patterns/audits/7BibTeX citation
@techreport{wshobson-wshobson-memory-safety-patterns-2026,
author = {wshobson},
title = {memory-safety-patterns security audit report (audit version 7)},
institution = {Skillstore},
year = {2026},
number = {7},
url = {https://skillstore.io/skills/wshobson-memory-safety-patterns/audits/7},
note = {Author version unspecified}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "memory-safety-patterns security audit report (audit version 7)"
version: "unspecified"
type: report
authors:
- name: "wshobson"
date-released: "2026-07-07"
url: "https://skillstore.io/skills/wshobson-memory-safety-patterns/audits/7"
identifiers:
- type: other
value: "skillstore:wshobson-memory-safety-patterns:audit:7"
description: "Skillstore immutable audit report identifier"
Compare variants
2 installable variantsEach author remains a separate installable skill. The recommended variant is ranked by Skillstore evidence.
Why this variant is first
sickn33-memory-safety-patterns
2026-09-09
wshobson-memory-safety-patterns
2026-09-09
Skillstore Score
Why this score Evidence Confidence: HighWhat You Can Build
Harden C++ Resource Management
Use RAII and smart pointer patterns to reduce leaks, double frees, and unsafe manual cleanup.
Plan Rust Ownership Models
Map shared state, borrowing, lifetimes, and concurrency choices before implementing Rust components.
Audit C Cleanup Paths
Review create and destroy flows, goto cleanup blocks, and local resource ownership contracts.
Try These Prompts
Explain the main memory safety risks in my C or C++ module. Focus on ownership, cleanup, and bounds checks.
Help me choose between unique ownership, shared ownership, borrowing, or cleanup functions for this resource design.
Review this C++ resource management design and suggest a RAII wrapper, move behavior, and safe destructor strategy.
Compare C, C++, and Rust approaches for this concurrency-heavy component. Recommend memory safety patterns and testing tools.
Best Practices
- Prefer ownership models that make cleanup automatic and visible.
- Use safe containers and checked access when correctness matters.
- Run sanitizers and memory tools on critical code paths.
Avoid
- Do not share mutable state without an explicit synchronization strategy.
- Do not hide resource ownership behind unclear raw pointer contracts.
- Do not copy examples without adapting error handling and lifecycle rules.