fix(diff): clamp Myers edit-distance operands to clear the allocation overflow alert#3775
Merged
Conversation
…tion Follow-up to #3773: that cleared the n+m addition alert, but CodeQL still flagged the 2*maxD allocation (go/allocation-size-overflow) because it doesn't propagate maxD's bound through the guarded sum. Clamp each line count to maxDiffEdits before summing, so the sum and the 2*maxD allocation both have constant-bounded operands. maxD stays min(n+m, maxDiffEdits).
| if cm > maxDiffEdits { | ||
| cm = maxDiffEdits | ||
| } | ||
| maxD := cn + cm |
SuMuxi66
pushed a commit
to SuMuxi66/DeepSeek-Reasonix
that referenced
this pull request
Jun 10, 2026
…tion (esengine#3775) Follow-up to esengine#3773: that cleared the n+m addition alert, but CodeQL still flagged the 2*maxD allocation (go/allocation-size-overflow) because it doesn't propagate maxD's bound through the guarded sum. Clamp each line count to maxDiffEdits before summing, so the sum and the 2*maxD allocation both have constant-bounded operands. maxD stays min(n+m, maxDiffEdits). Co-authored-by: reasonix <reasonix@deepseek.com>
dorokuma
pushed a commit
to dorokuma/DeepSeek-Reasonix
that referenced
this pull request
Jun 10, 2026
…tion (esengine#3775) Follow-up to esengine#3773: that cleared the n+m addition alert, but CodeQL still flagged the 2*maxD allocation (go/allocation-size-overflow) because it doesn't propagate maxD's bound through the guarded sum. Clamp each line count to maxDiffEdits before summing, so the sum and the 2*maxD allocation both have constant-bounded operands. maxD stays min(n+m, maxDiffEdits). Co-authored-by: reasonix <reasonix@deepseek.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #3773 to clear the remaining CodeQL
go/allocation-size-overflowalert.#3773 cleared the
n + maddition alert, but CodeQL kept flagging themake([]int, 2*maxD+1)allocation: it doesn't propagatemaxD's upper bound through the guarded sum, so it can't prove2*maxDwon't overflow.This clamps each line count to
maxDiffEditsbefore summing (cn,cm), so both the sum and the2*maxDallocation have operands bounded by a constant — the canonical barrier CodeQL recognizes.maxDstaysmin(n+m, maxDiffEdits), identical behavior.go build+go test ./internal/diff/pass locally.