Skip to content

Commit 2579aaf

Browse files
author
Release Manager
committed
sagemathgh-41111: Fix a segmentation fault in Jacobian() See the newly added test, previously it segmentation faults. the reason is the inner loop `loop_over_rectangular_box_points` accesses `i_min = box_min[0]` without any bound checking, this will segmentation fault if `box_min` is empty. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#41111 Reported by: user202729 Reviewer(s): Kwankyu Lee, user202729
2 parents 8a777f0 + 2575e20 commit 2579aaf

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/sage/geometry/integral_points.pxi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,17 @@ cpdef rectangular_box_points(list box_min, list box_max,
533533
sage: P = Polyhedron(ieqs=ieqs)
534534
sage: from sage.doctest.util import ensure_interruptible_after
535535
sage: with ensure_interruptible_after(0.5): P.integral_points()
536+
537+
Check that the following doesn't segmentation fault
538+
(the error message could be improved)::
539+
540+
sage: rectangular_box_points([], [])
541+
Traceback (most recent call last):
542+
...
543+
AssertionError
536544
"""
537545
assert len(box_min) == len(box_max)
546+
assert box_min
538547
assert not (count_only and return_saturated)
539548
cdef int d = len(box_min)
540549
cdef int i, j

src/sage/schemes/elliptic_curves/jacobian.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ def Jacobian(X, **kwds):
9696
(-u^4*v^4*w - u^4*v*w^4 - u*v^4*w^4 :
9797
1/2*u^6*v^3 - 1/2*u^3*v^6 - 1/2*u^6*w^3 + 1/2*v^6*w^3 + 1/2*u^3*w^6 - 1/2*v^3*w^6 :
9898
u^3*v^3*w^3)
99+
100+
TESTS:
101+
102+
Check that the following doesn't segmentation fault
103+
(the error message could be improved)::
104+
105+
sage: Jacobian(GF(11)['x,y'](3))
106+
Traceback (most recent call last):
107+
...
108+
AssertionError
99109
"""
100110
try:
101111
return X.jacobian(**kwds)

0 commit comments

Comments
 (0)