Skip to content

Commit 7b3c776

Browse files
committed
fix gurobi_vars mem leak
1 parent 3edf30c commit 7b3c776

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

LP.c

+11
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,13 @@ int fill_board(Board *board, int is_integer, float threshold)
622622
vars = initilize_gurobi_vars(num_of_params, board);
623623
sol = run_LP(board, is_integer, vars, num_of_params);
624624
if (sol == NULL)
625+
{
626+
if (vars != NULL)
627+
{
628+
free(vars);
629+
}
625630
return 0;
631+
}
626632

627633
fill_results_to_board(board, sol, threshold, vars, num_of_params);
628634
free(vars);
@@ -645,6 +651,11 @@ OptionalCellValues get_value_for_cell(Board *board, int row, int column, int is_
645651
if (sol == NULL)
646652
{
647653
*is_succedded = 0;
654+
if (vars != NULL)
655+
{
656+
free(vars);
657+
}
658+
648659
return cell_values;
649660
}
650661

0 commit comments

Comments
 (0)