Skip to content

Comments

Fix immediate crash in Trim Trailing Spaces#36

Merged
rainman74 merged 2 commits intomainfrom
codex/fix-access-violation-in-trim-trailing-spaces
Feb 17, 2026
Merged

Fix immediate crash in Trim Trailing Spaces#36
rainman74 merged 2 commits intomainfrom
codex/fix-access-violation-in-trim-trailing-spaces

Conversation

@rainman74
Copy link
Owner

Motivation

  • The Trim Trailing Spaces action was causing an immediate application crash due to brittle pointer arithmetic while computing and removing trailing spaces.
  • A previous change still reused a single mutable pointer for multiple roles which left room for invalid pointer math and triggered the reported crash.

Description

  • Rewrote trimtrailingspace to use explicit pointers lineend and trimstart instead of reusing the scan pointer, making the roles of source and destination positions distinct.
  • Compute the trailing-space length as lold = (unsigned)(lineend - trimstart) and call memmovetest with trimstart + lnew as destination and lineend as source to make source/destination math explicit.
  • Update the loop to advance with d = memspn(lineend, end, "\r\n", 2) and set lineend = trimstart after a move to preserve trimming semantics without unsafe arithmetic.

Testing

  • No automated tests were executed in this environment.

Codex Task

@rainman74 rainman74 merged commit d48d397 into main Feb 17, 2026
12 checks passed
@rainman74 rainman74 deleted the codex/fix-access-violation-in-trim-trailing-spaces branch February 17, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant