Skip to content

Commit 8e96f10

Browse files
committed
Fix HomalgIdentityMatrix: Singular segfaults for n=0
Singular.identity_matrix(R, 0) calls mp_InitP(0,...) which causes a segmentation fault. Return a zero_matrix(R, 0, 0) instead for n=0.
1 parent c508901 commit 8e96f10

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

ext/MatricesForHomalgSingularExt.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,12 @@ julia> HomalgIdentityMatrix(2, R)
345345
```
346346
"""
347347
function MatricesForHomalg.HomalgIdentityMatrix(r, R::Singular.PolyRing)
348-
return Singular.identity_matrix(R, Int(r))
348+
n = Int(r)
349+
# Singular.identity_matrix segfaults for n=0; return a zero matrix instead
350+
if n == 0
351+
return Singular.zero_matrix(R, 0, 0)
352+
end
353+
return Singular.identity_matrix(R, n)
349354
end
350355

351356
## RandomMatrix for Singular rings

0 commit comments

Comments
 (0)