Skip to content

Commit fa37618

Browse files
committed
Validate cstat/rstat lengths in LP.setBase
1 parent 32a156c commit fa37618

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/pyscipopt/lp.pxi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,12 @@ cdef class LP:
571571
Row basis statuses (length must equal nrows).
572572
573573
"""
574-
cdef int ncols = len(cstat)
575-
cdef int nrows = len(rstat)
574+
cdef int ncols = self.ncols()
575+
cdef int nrows = self.nrows()
576+
if len(cstat) != ncols:
577+
raise ValueError(f"cstat has length {len(cstat)}, expected {ncols}")
578+
if len(rstat) != nrows:
579+
raise ValueError(f"rstat has length {len(rstat)}, expected {nrows}")
576580
cdef int* c_cstat = <int*> malloc(ncols * sizeof(int))
577581
cdef int* c_rstat = <int*> malloc(nrows * sizeof(int))
578582
cdef int i

0 commit comments

Comments
 (0)