Skip to content

integer underflow fix#95

Merged
freemans13 merged 3 commits into
bsv-blockchain:mainfrom
freemans13:bug/integer-underflow-fix
Nov 4, 2025
Merged

integer underflow fix#95
freemans13 merged 3 commits into
bsv-blockchain:mainfrom
freemans13:bug/integer-underflow-fix

Conversation

@freemans13

Copy link
Copy Markdown
Collaborator

No description provided.

@freemans13 freemans13 self-assigned this Oct 31, 2025
@freemans13 freemans13 merged commit 8605872 into bsv-blockchain:main Nov 4, 2025
11 of 12 checks passed
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2025

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

🤖 Claude Code Review

Status: Complete


Review Summary:

This PR correctly fixes an integer underflow bug in the UTXO persister service. The fix prevents underflow when calculating maxHeight = bestBlockMeta.Height - 100 during early chain bootstrapping (when height < 100).

Analysis:

Correct fix: The guard condition properly handles the edge case by setting maxHeight = bestBlockMeta.Height when height < 100, avoiding unsigned integer underflow.

Type safety: Both bestBlockMeta.Height and maxHeight are uint32, making the comparison and assignment type-safe.

Logic preserved: For chains with ≥100 blocks, the existing 100-confirmation safety window is maintained.

Comment quality: Clear inline comments explain the rationale for the fix.

No issues found. The implementation is clean and addresses the underflow bug without introducing new problems.

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.

3 participants