Skip to content

Fix crash when a process's ps arguments string is empty - #1

Merged
AadhilFarhan merged 1 commit into
mainfrom
fix/process-details-empty-args
Jul 20, 2026
Merged

Fix crash when a process's ps arguments string is empty#1
AadhilFarhan merged 1 commit into
mainfrom
fix/process-details-empty-args

Conversation

@AadhilFarhan

Copy link
Copy Markdown
Owner

What

ProcessDetails.executable force-indexed arguments.split(separator: " ")[0], which traps (fatal error, not a catchable Swift error) when arguments is empty — confirmed by running the split in isolation.

Currently unreachable in practice only because PsParser.parse happens to never produce an empty arguments string (its own fields.count >= 5 guard enforces that indirectly) — but ProcessDetails is a public type with a public initializer that doesn't itself validate arguments, so any other caller constructing one directly and reading .executable would crash.

Fix

Guard the split result instead of force-indexing; return "" for empty input, matching the rest of the codebase's degrade-don't-crash convention (documented in CLAUDE.md).

Test plan

  • Added testEmptyArgumentsDoesNotCrash, which would have crashed the whole test binary on the old code (fatal traps aren't catchable) — the fix's guard makes it pass cleanly.
  • Full suite: 10/10 passing.

ProcessDetails.executable force-indexed the result of splitting the
arguments string, which traps on an out-of-bounds access when the
string is empty rather than degrading gracefully like the rest of the
scanning pipeline.
@AadhilFarhan
AadhilFarhan merged commit bdedcf5 into main Jul 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant