Skip to content

Commit

Permalink
sagemathgh-37861: Fix segfault for Weil polynomials
Browse files Browse the repository at this point in the history
    
Fix segfault for Weil polynomials

Eliminate a segfault that occurs when asking for Weil polynomials of
degree 0 and sign -1 (which do not exist, so the iterator should return
empty). This fixes sagemath#37860.
    
URL: sagemath#37861
Reported by: kedlaya
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed May 12, 2024
2 parents 6fa34e7 + 95d8bea commit ee5f606
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sage/rings/polynomial/weil/weil_polynomials.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class WeilPolynomials_iter():
if node_limit is None:
node_limit = -1
force_squarefree = Integer(squarefree)
self.process = dfs_manager(d2, q, coefflist, modlist, coeffsign,
self.process = None if d2<0 else dfs_manager(d2, q, coefflist, modlist, coeffsign,
num_cofactor, node_limit, parallel,
force_squarefree)
self.q = q
Expand Down Expand Up @@ -537,7 +537,12 @@ class WeilPolynomials():
sage: list(WeilPolynomials(10, 2, lead=(1,-3,5,-5,5,-5)))
[x^10 - 3*x^9 + 5*x^8 - 5*x^7 + 5*x^6 - 5*x^5 + 10*x^4 - 20*x^3 + 40*x^2 - 48*x + 32]
Test that :issue:`37860` is resolved::
sage: list(WeilPolynomials(-1, 1))
[]
sage: list(WeilPolynomials(0, 1, sign=-1))
[]
"""
def __init__(self, d, q, sign=1, lead=1, node_limit=None, parallel=False, squarefree=False, polring=None):
r"""
Expand Down

0 comments on commit ee5f606

Please sign in to comment.