Skip to content

Commit 8832503

Browse files
committed
Merge remote-tracking branch 'origin/v10-minor'
2 parents 5422099 + c02c187 commit 8832503

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ Fixed bugs
419419
- fixed detection of sinks in varbound detection from cumulative constraints
420420
- fixed memory allocation when adding strong SBCs for enclosing orbit of symmetric subgroups (disabled by default)
421421
- free paths of branch-and-bound tree iteratively instead of recursively to avoid stack overflow
422+
- fixed rare invalid memory access when collecting symmetry information for indicator constraints
422423

423424
Build system
424425
------------

src/scip/cons_indicator.c

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -476,21 +476,16 @@ SCIP_RETCODE addSymmetryInformation(
476476
SCIP_CONS* lincons;
477477
SCIP_VAR** vars;
478478
SCIP_Real* vals;
479-
SCIP_VAR** linvars;
480-
SCIP_Real* linvals;
481479
SCIP_Real constant;
482480
SCIP_Real lhs;
483481
SCIP_Real rhs;
484-
SCIP_Bool suc;
485482
int slacknodeidx;
486483
int consnodeidx;
487484
int eqnodeidx;
488485
int opnodeidx;
489486
int nodeidx;
490487
int nvarslincons;
491488
int nlocvars;
492-
int nvars;
493-
int i;
494489

495490
assert(scip != NULL);
496491
assert(cons != NULL);
@@ -503,28 +498,19 @@ SCIP_RETCODE addSymmetryInformation(
503498
lincons = consdata->lincons;
504499
assert(lincons != NULL);
505500

506-
SCIP_CALL( SCIPgetConsNVars(scip, lincons, &nvarslincons, &suc) );
507-
assert(suc);
508-
501+
/* get information about linear constraint */
509502
lhs = SCIPgetLhsLinear(scip, lincons);
510503
rhs = SCIPgetRhsLinear(scip, lincons);
504+
nvarslincons = SCIPgetNVarsLinear(scip, lincons);
511505

512-
/* get information about linear constraint */
513-
nvars = SCIPgetNVars(scip);
514-
515-
SCIP_CALL( SCIPallocBufferArray(scip, &vars, nvars) );
516-
SCIP_CALL( SCIPallocBufferArray(scip, &vals, nvars) );
517-
518-
linvars = SCIPgetVarsLinear(scip, lincons);
519-
linvals = SCIPgetValsLinear(scip, lincons);
520-
for( i = 0; i < nvarslincons; ++i )
521-
{
522-
vars[i] = linvars[i];
523-
vals[i] = linvals[i];
524-
}
525-
nlocvars = nvarslincons;
506+
nlocvars = MAX3(1, nvarslincons, SCIPgetNVars(scip)); /*lint !e666*/
507+
SCIP_CALL( SCIPallocBufferArray(scip, &vars, nlocvars) );
508+
SCIP_CALL( SCIPallocBufferArray(scip, &vals, nlocvars) );
509+
BMScopyMemoryArray(vars, SCIPgetVarsLinear(scip, lincons), nvarslincons);
510+
BMScopyMemoryArray(vals, SCIPgetValsLinear(scip, lincons), nvarslincons);
526511

527512
constant = 0.0;
513+
nlocvars = nvarslincons;
528514
SCIP_CALL( SCIPgetSymActiveVariables(scip, symtype, &vars, &vals, &nlocvars, &constant, SCIPisTransformed(scip)) );
529515

530516
/* update lhs/rhs due to possible variable aggregation */

0 commit comments

Comments
 (0)