summaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2014-11-09 20:17:29 +0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-10 12:17:37 -0800
commit4753d5c15c7a1e9e4acf04e3aa72ead8ab72a363 (patch)
treeeb5dc89f10ba974228f68f992ccb91c1ddb994e6 /file.c
parent9cf7a5d9682414a72488defbc3a1e30a9fe9e25a (diff)
downloadsubsurface-4753d5c15c7a1e9e4acf04e3aa72ead8ab72a363.tar.gz
Fix memory leak
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'file.c')
-rw-r--r--file.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/file.c b/file.c
index 685a80b9d..29bbea5a8 100644
--- a/file.c
+++ b/file.c
@@ -487,7 +487,9 @@ int parse_txt_file(const char *filename, const char *csv)
dive = alloc_dive();
dive->when = utc_mktime(&cur_tm);;
dive->dc.model = strdup("Poseidon MkVI Discovery");
- dive->dc.deviceid = atoi(parse_mkvi_value(memtxt.buffer, "Rig Serial number"));
+ value = parse_mkvi_value(memtxt.buffer, "Rig Serial number");
+ dive->dc.deviceid = atoi(value);
+ free(value);
dive->dc.dctype = CCR;
dive->dc.no_o2sensors = 2;
@@ -502,8 +504,12 @@ int parse_txt_file(const char *filename, const char *csv)
dive->cylinder[cur_cylinder_index].type.size.mliter = 3000;
dive->cylinder[cur_cylinder_index].type.workingpressure.mbar = 200000;
dive->cylinder[cur_cylinder_index].type.description = strdup("3l Mk6");
- he = atoi(parse_mkvi_value(memtxt.buffer, "Helium percentage"));
- dive->cylinder[cur_cylinder_index].gasmix.o2.permille = (100 - atoi(parse_mkvi_value(memtxt.buffer, "Nitrogen percentage")) - he) * 10;
+ value = parse_mkvi_value(memtxt.buffer, "Helium percentage");
+ he = atoi(value);
+ free(value);
+ value = parse_mkvi_value(memtxt.buffer, "Nitrogen percentage");
+ dive->cylinder[cur_cylinder_index].gasmix.o2.permille = (100 - atoi(value) - he) * 10;
+ free(value);
dive->cylinder[cur_cylinder_index].gasmix.he.permille = he * 10;
cur_cylinder_index++;