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 */