From: Michael Schroeder Date: Wed, 3 Jun 2020 12:27:10 +0000 (+0200) Subject: Fix all memory errors found in 'make test' X-Git-Tag: 0.7.15~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=437820ed28ecf3a1d642d21a6713d3b6089a07db;p=thirdparty%2Flibsolv.git Fix all memory errors found in 'make test' Based on pull request #391 by Aaron D. Marasco. Thanks! --- diff --git a/src/selection.c b/src/selection.c index 5f01e2b5..a8e60f79 100644 --- a/src/selection.c +++ b/src/selection.c @@ -150,6 +150,7 @@ selection_flatten(Pool *pool, Queue *selection) if (!q.count) { queue_empty(selection); + queue_free(&q); return; } queue_truncate(selection, 2); @@ -163,6 +164,7 @@ selection_flatten(Pool *pool, Queue *selection) selection->elements[0] = SOLVER_SOLVABLE | SOLVER_NOAUTOSET; selection->elements[1] = q.elements[0]; } + queue_free(&q); } /* only supports simple rels plus REL_ARCH */ diff --git a/tools/testsolv.c b/tools/testsolv.c index 18dfcfe1..a9e67ec7 100644 --- a/tools/testsolv.c +++ b/tools/testsolv.c @@ -66,6 +66,16 @@ reportsolutioncb(Solver *solv, void *cbdata) return 0; } +static void +free_considered(Pool *pool) +{ + if (pool->considered) + { + map_free(pool->considered); + pool->considered = solv_free(pool->considered); + } +} + int main(int argc, char **argv) { @@ -149,7 +159,9 @@ main(int argc, char **argv) solv = testcase_read(pool, fp, argv[optind], &job, &result, &resultflags); if (!solv) { + free_considered(pool); pool_free(pool); + queue_free(&job); exit(resultflags == 77 ? 77 : 1); } if (reusesolv) @@ -349,6 +361,7 @@ main(int argc, char **argv) } if (reusesolv) solver_free(reusesolv); + free_considered(pool); pool_free(pool); fclose(fp); }