[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 368bade 1/2: Fix memory leak in mkcatalog
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 368bade 1/2: Fix memory leak in mkcatalog |
Date: |
Fri, 26 May 2017 09:06:06 -0400 (EDT) |
branch: master
commit 368bade4eef86eb603378ef7a8dff7c0a7a0eb69
Author: Vladimir Markelov <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Fix memory leak in mkcatalog
Memory allocated by `asprintf' should be freed. Most of the similar
allocations are added to list using `gal_list_str_add' and then memory is
freed when the list is deleted. But `tstr' is a temporary variable and
should be freed manually after use.
Assigning NULL to the variable is not necessary but I did it just in case
the variable will be used later in this function.
This fixes bug #51118.
---
bin/mkcatalog/mkcatalog.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/bin/mkcatalog/mkcatalog.c b/bin/mkcatalog/mkcatalog.c
index cb901cb..7c43c98 100644
--- a/bin/mkcatalog/mkcatalog.c
+++ b/bin/mkcatalog/mkcatalog.c
@@ -756,6 +756,10 @@ mkcatalog_outputs_same_start(struct mkcatalogparams *p,
int o0c1,
* sqrt( p->sfmagarea / pixarea) )
+ p->zeropoint ) );
gal_list_str_add(&comments, str, 0);
+ if (tstr) {
+ free(tstr);
+ tstr = NULL;
+ }
}
/* Notice: */