Skip to content

fix: guard polynomial multiplication against empty coefficients#2815

Open
1sgtpepper wants to merge 3 commits into
succinctlabs:mainfrom
1sgtpepper:fix-empty-polynomial-mul
Open

fix: guard polynomial multiplication against empty coefficients#2815
1sgtpepper wants to merge 3 commits into
succinctlabs:mainfrom
1sgtpepper:fix-empty-polynomial-mul

Conversation

@1sgtpepper

Copy link
Copy Markdown

Summary

Fix empty coefficient handling in polynomial multiplication.

When either operand has no coefficients, the result length calculation can underflow before allocation:

self.coefficients.len() + other.coefficients.len() - 1

This returns an empty polynomial early for both owned and borrowed multiplication in the two current polynomial implementations.

Fixes #2639.

Verification

  • git diff --check
  • cargo metadata --no-deps --format-version 1

@1sgtpepper 1sgtpepper changed the title Guard polynomial multiplication against empty coefficients fix: guard polynomial multiplication against empty coefficients May 23, 2026
@1sgtpepper 1sgtpepper marked this pull request as ready for review May 23, 2026 14:10
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.

Potential usize underflow in UnivariatePolynomial multiplication

1 participant