Skip to content

Commit 2bc0ab8

Browse files
committed
return None at not success
1 parent 4b2e48a commit 2bc0ab8

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/pyscipopt/scip.pxi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6033,6 +6033,10 @@ cdef class Model:
60336033
_vars = <SCIP_VAR**> malloc(nvars * sizeof(SCIP_VAR*))
60346034
SCIPgetConsVars(self._scip, constraint.scip_cons, _vars, nvars, &success)
60356035

6036+
if not success:
6037+
free(_vars)
6038+
return None
6039+
60366040
vars = []
60376041
for i in range(nvars):
60386042
ptr = <size_t>(_vars[i])
@@ -6046,6 +6050,7 @@ cdef class Model:
60466050
self._modelvars[ptr] = var
60476051
vars.append(var)
60486052

6053+
free(_vars)
60496054
return vars
60506055

60516056
def getConsVals(self, Constraint constraint):
@@ -6071,6 +6076,10 @@ cdef class Model:
60716076
vals = <SCIP_Real*> malloc(nvars * sizeof(SCIP_Real))
60726077
PY_SCIP_CALL(SCIPgetConsVals(self._scip, constraint.scip_cons, vals, nvars, &success))
60736078

6079+
if not success:
6080+
free(vals)
6081+
return None
6082+
60746083
result = [vals[i] for i in range(nvars)]
60756084
free(vals)
60766085
return result

0 commit comments

Comments
 (0)