Skip to content

Commit 78bd23b

Browse files
committed
Fix segmentation fault in singular interface code
1 parent 1be0a58 commit 78bd23b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/sage/libs/singular/singular.pyx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,13 +1403,6 @@ cdef number *sa2si_NF(object elem, ring *_ring) noexcept:
14031403
cdef number *apow1
14041404
cdef number *apow2
14051405

1406-
cdef nMapFunc nMapFuncPtr = NULL
1407-
1408-
nMapFuncPtr = naSetMap(_ring.cf, currRing.cf) # choose correct mapping function
1409-
1410-
if nMapFuncPtr is NULL:
1411-
raise RuntimeError("Failed to determine nMapFuncPtr")
1412-
14131406
elem = list(elem)
14141407

14151408
if _ring != currRing:
@@ -1432,7 +1425,10 @@ cdef number *sa2si_NF(object elem, ring *_ring) noexcept:
14321425
rComplete(qqr,1)
14331426
qqr.ShortOut = 0
14341427

1435-
nMapFuncPtr = naSetMap(qqr.cf, _ring.cf) # choose correct mapping function
1428+
assert _ring.cf.type == n_algExt # if false naSetMap will segmentation fault (should never happen)
1429+
cdef nMapFunc nMapFuncPtr = naSetMap(qqr.cf, _ring.cf) # choose correct mapping function
1430+
if nMapFuncPtr is NULL:
1431+
raise RuntimeError("Failed to determine nMapFuncPtr")
14361432
cdef poly *_p
14371433
for i from 0 <= i < len(elem):
14381434
nlCoeff = nlInit2gmp( mpq_numref((<Rational>elem[i]).value), mpq_denref((<Rational>elem[i]).value), qqr.cf )

0 commit comments

Comments
 (0)