Skip to content

fix(queue): prevent usize underflow in frame_queue prune when queue is empty#1751

Open
lavidaloca26 wants to merge 1 commit intobase:mainfrom
lavidaloca26:fix/frame-queue-underflow
Open

fix(queue): prevent usize underflow in frame_queue prune when queue is empty#1751
lavidaloca26 wants to merge 1 commit intobase:mainfrom
lavidaloca26:fix/frame-queue-underflow

Conversation

@lavidaloca26
Copy link
Copy Markdown

Problem

The FrameQueue::prune() function has an off-by-one error that causes a usize underflow panic. When the queue has fewer than 2 elements, the expression self.queue.len() - 1 underflows because usize is unsigned in Rust.

Fix

Added an early return check if self.queue.len() < 2 { return; } before the while loop to prevent the underflow. This is safe because the pruning logic requires at least 2 frames to compare.

Why change is safe

  • Early return preserves existing behavior for empty or single-frame queues (nothing to prune)
  • The pruning logic only operates on consecutive frame pairs, requiring 2+ frames
  • No breaking changes to API or external behavior
  • Defensive fix that prevents panic while maintaining correctness

@cb-heimdall
Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 28, 2026

Someone is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

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.

2 participants