8000 FIX memory leak in liblinear (#9024) · jwjohnson314/scikit-learn@967e8c3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 967e8c3

Browse files
superbobryJeremiah Johnson
authored and
Jeremiah Johnson
committed
FIX memory leak in liblinear (scikit-learn#9024)
The leak resulted from two issues: - not freeing the problem struct - not freeing the number of iterations The former was present in the initial version of ``liblinear_helper.c`` while latter appeared after c8c72fd which introduced ``n_iter``. Closes scikit-learn#8499
1 parent c8db6ba commit 967e8c3

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

sklearn/svm/src/liblinear/liblinear_helper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ void free_problem(struct problem *problem)
219219
int i;
220220
for(i=problem->l-1; i>=0; --i) free(problem->x[i]);
221221
free(problem->x);
222+
free(problem);
222223
}
223224

224225
void free_parameter(struct parameter *param)

sklearn/svm/src/liblinear/linear.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,6 +2910,8 @@ void free_model_content(struct model *model_ptr)
29102910
free(model_ptr->w);
29112911
if(model_ptr->label != NULL)
29122912
free(model_ptr->label);
2913+
if(model_ptr->n_iter != NULL)
2914+
free(model_ptr->n_iter);
29132915
}
29142916

29152917
void free_and_destroy_model(struct model **model_ptr_ptr)

0 commit comments

Comments
 (0)
0