Help us improve
Share bugs, ideas, or general feedback.
From soundcheck
Detects function-local misuse of memory and resource APIs in C, C++, and Rust unsafe — unchecked allocations, double-frees, uninitialized locks, and fd leaks across exec. Use when writing or reviewing low-level code that calls malloc, mmap, pthread_mutex, fopen, or raw FFI pointer APIs.
npx claudepluginhub thejefflarson/soundcheck --plugin soundcheckHow this skill is triggered — by the user, by Claude, or both
Slash command
/soundcheck:memory-api-misuseThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
C, C++, and Rust unsafe memory and resource APIs called incorrectly at a single call
Implements memory-safe programming patterns including RAII, ownership, smart pointers, and resource management across Rust, C++, and C. Use when writing safe systems code or preventing memory bugs.
Use AddressSanitizer to detect memory safety bugs in C/C++ programs. Identifies use-after-free, buffer overflow, memory leaks, and other memory errors.
Provides cross-language patterns for memory-safe programming including RAII, ownership, smart pointers, and resource management. Useful for systems code, resource handling, preventing leaks and use-after-free.
Share bugs, ideas, or general feedback.
C, C++, and Rust unsafe memory and resource APIs called incorrectly at a single call
site — a NULL return dereferenced, a double-free on an error path, a lock used
before init, a file descriptor that survives exec(). Existing static analyzers
catch the easy cases; this skill targets the ones that read clean on first pass but
fail in error or cleanup paths. It does local pattern matching at the call site,
not whole-program lifetime analysis (that's the job of TSAN, ASAN, Valgrind, and the
Rust borrow checker).
malloc, calloc, mmap, equivalent) whose return is used without a NULL or MAP_FAILED check before the next dereferencerealloc whose return value overwrites the original pointer in place, leaking the original allocation if reallocation failsfopen, open, equivalent) that opens an fd which must not survive exec() without the close-on-exec mode or flag setunsafe block that calls a raw FFI allocation or pointer API and dereferences the result with no NULL checkfree (or equivalent) on a pointer with no immediate nulling, leaving the dangling pointer available for later use-after-freeFlag the vulnerable call site and rewrite it so the API return value is checked and cleanup runs exactly once per allocation. Establish these properties:
MAP_FAILED return
turns into a controlled error path — never a silent dereference.realloc results land in a temporary first. The original pointer remains
valid on failure so the caller can free it deterministically; the original
pointer is overwritten only after success is confirmed.defer/scope_exit — never free the same allocation
on both an error branch and a shared cleanup path.exec() are opened close-on-exec.
Use the close-on-exec mode flag at open time, not a follow-up fcntl race.Translate these principles to the specific allocator, lock, and fd API of the audited file. Use the platform's documented safe forms — do not invent variants.
After rewriting, confirm:
exec() is opened with the close-on-exec flag or mode at open timeunsafe, every raw pointer obtained from an FFI API is checked for NULL before dereference or slice construction