Skip to content

Commit 36b43a4

Browse files
committed
fix allocation of zero matrices
1 parent 1b8c416 commit 36b43a4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/sage/matrix/matrix_modn_dense_template.pxi

+6
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,13 @@ cdef class Matrix_modn_dense_template(Matrix_dense):
451451
else:
452452
self._entries = <celement *> check_allocarray(self._nrows * self._ncols, sizeof(celement))
453453

454+
# TODO: it is a bit of a waste to allocate _matrix when ncols=0. Though some
455+
# of the code expects self._matrix[i] to be valid, even though it points to
456+
# an empty vector.
454457
self._matrix = <celement **> check_allocarray(self._nrows, sizeof(celement*))
458+
if self._nrows == 0:
459+
return
460+
455461
cdef Py_ssize_t i
456462
self._matrix[0] = self._entries
457463
for i in range(self._nrows - 1):

0 commit comments

Comments
 (0)