Skip to content

Comments

Validate block selection bounds, trim trailing tabs, and guard poplist adjustments#43

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

Validate block selection bounds, trim trailing tabs, and guard poplist adjustments#43
rainman74 merged 2 commits intomainfrom
codex/fix-access-violation-in-trim-trailing-spaces

Conversation

@rainman74
Copy link
Owner

Motivation

  • Prevent remaining Access Violations in convertall caused by invalid per-line block selection positions returned from Scintilla.
  • Ensure trailing horizontal tabs are treated as removable whitespace by trimtrailingspace so trailing whitespace is fully trimmed.
  • Avoid unsigned wrap/underflow when adjusting stored poplist positions after edits.

Description

  • Read SCI_GETLINESELSTARTPOSITION/SCI_GETLINESELENDPOSITION into Sci_Position (ls/le) and validate against INVALID_POSITION and le < ls, neutralizing invalid lines with lps[ln]=lpe[ln]=0 so they are skipped during replacements.
  • Advance block-mode input parsing with memspn in the per-line replacement loop and ensure we never pass invalid offsets to SCI_SETTARGETSTART/END/SCI_REPLACETARGET.
  • Update trimtrailingspace to treat \t as whitespace (so both spaces and tabs are removed at line ends) and simplify the trimming logic accordingly.
  • Harden adjustprplist to avoid unsigned underflow by checking lengths before adding or subtracting and clamping indexes when necessary.

Testing

  • Inspected modified lines with nl -ba SRC/NPPTextFX.cpp | sed -n '3674,3680p;4825,4838p;4954,4961p' which showed the intended changes and succeeded.
  • Verified repository changes with git diff --stat -- SRC/NPPTextFX.cpp and created a commit with git commit -m, both operations succeeded.
  • Generated PR metadata and summary using the local mcp__make_pr__make_pr helper which produced the PR title/body; no Notepad++/Scintilla runtime tests were available in this environment.

Codex Task

@rainman74 rainman74 merged commit ac8c976 into main Feb 17, 2026
@rainman74 rainman74 deleted the codex/fix-access-violation-in-trim-trailing-spaces branch February 17, 2026 18:54
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