From 5a8878718c76597f058aee140215d4bc6f31591b Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 7 Oct 2012 16:09:05 +0200 Subject: [PATCH] Fixed memory leak in recutl_write_db_to_file The array tmp_file_name was being allocated, but never freed. There is however no need for this memory to be on the heap. Having it on the stack saves a copy operation and avoids the need to alloc/free is completely. --- ChangeLog | 4 ++++ utils/recutl.c | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e5955f..375fcea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2012-10-07 John Darrington + + utils/recutl.c: (recutl_write_db_to_file) Fixed memory leak + 2012-09-07 Jose E. Marchesi rec-mode: fixed to allow comments in records. diff --git a/utils/recutl.c b/utils/recutl.c index 7fe5e58..e2a9d13 100644 --- a/utils/recutl.c +++ b/utils/recutl.c @@ -350,7 +350,7 @@ recutl_write_db_to_file (rec_db_t db, char *file_name) { FILE *out; - char *tmp_file_name; + char tmp_file_name[10]="recXXXXXX"; rec_writer_t writer; int des; struct stat st1; @@ -366,8 +366,6 @@ recutl_write_db_to_file (rec_db_t db, stat_result = stat (file_name, &st1); /* Create a temporary file with the results. */ - tmp_file_name = xmalloc (100); - strcpy (tmp_file_name, "recXXXXXX"); des = mkstemp (tmp_file_name); if (des == -1) { -- 1.7.2.5