From 415bc43898fa0ddff60a61535f19c790fac9022a Mon Sep 17 00:00:00 2001 From: David Declerck Date: Mon, 27 Jan 2025 10:24:51 +0100 Subject: [PATCH] Merge SVN 5163 --- libcob/ChangeLog | 1 + libcob/fileio.c | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libcob/ChangeLog b/libcob/ChangeLog index e2cf4658..903f79d8 100644 --- a/libcob/ChangeLog +++ b/libcob/ChangeLog @@ -72,6 +72,7 @@ * screenio.c, common.c: replace use of NCURSES_MOUSE_VERSION by HAVE_MOUSEMASK + * fileio.c (cob_file_sort_giving_internal): fix memory cleanup 2023-07-27 Chuck Haatvedt diff --git a/libcob/fileio.c b/libcob/fileio.c index 2fb4ddae..260f9787 100644 --- a/libcob/fileio.c +++ b/libcob/fileio.c @@ -9657,13 +9657,6 @@ cob_file_sort_giving_internal (cob_file *sort_file, const size_t giving_cnt, } } - /* cleanup temporary arrays */ - cob_free (opt); - cob_free (fbase); - if (callfh) { - cob_free (callfh); - } - /* if any error happened with the GIVING files update SORT-RETURN */ if (hp->sort_return) { for (i = 0; i < giving_cnt; ++i) { @@ -9673,6 +9666,13 @@ cob_file_sort_giving_internal (cob_file *sort_file, const size_t giving_cnt, } } } + + /* cleanup temporary arrays */ + cob_free (opt); + cob_free (fbase); + if (callfh) { + cob_free (callfh); + } } /* SORT: WRITE all records from 'sort_file' to all passed USING files */