summaryrefslogtreecommitdiffstats
path: root/smtk-import/smartrak.c
diff options
context:
space:
mode:
authorGravatar Salvador Cuñat <salvador.cunat@gmail.com>2017-02-24 00:09:06 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-02-25 09:19:48 -0800
commitc2997c33c722ab075592ad0c5cb766a52aa7c90c (patch)
treee49e267fc925714573cc3c09622f9e97a65d58da /smtk-import/smartrak.c
parent0f56a1e4bf0437d907d70af5228244c26e21b400 (diff)
downloadsubsurface-c2997c33c722ab075592ad0c5cb766a52aa7c90c.tar.gz
smtk-import: Fix freeing unallocated memory
hdr_buffer pointer was not always allocated (just on dc dives), but was always freed. This should cause a crash while processing a manually added dive (or a dive whose dc model couldn't be stablished), but not always does, crashes only if the pointed memory hasn't been previously allocated. In most cases causes memory corruption, which goes easily unnoticed as it is correctly freed in next parse run. This means, obviously, I have some work TODO fixing leaks with valgrind. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Diffstat (limited to 'smtk-import/smartrak.c')
-rw-r--r--smtk-import/smartrak.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/smtk-import/smartrak.c b/smtk-import/smartrak.c
index e5ae5c78d..c1d22ff9e 100644
--- a/smtk-import/smartrak.c
+++ b/smtk-import/smartrak.c
@@ -724,6 +724,7 @@ void smartrak_import(const char *file, struct dive_table *divetable)
smtkdive->dc.duration.seconds = smtkdive->duration.seconds = smtk_time_to_secs(col[coln(DURATION)]->bind_ptr);
smtkdive->dc.maxdepth.mm = smtkdive->maxdepth.mm = strtod(col[coln(MAXDEPTH)]->bind_ptr, NULL) * 1000;
}
+ free(hdr_buffer);
free(prf_buffer);
} else {
/* Manual dives or unknown DCs */
@@ -731,7 +732,6 @@ void smartrak_import(const char *file, struct dive_table *divetable)
smtkdive->dc.duration.seconds = smtkdive->duration.seconds = smtk_time_to_secs(col[coln(DURATION)]->bind_ptr);
smtkdive->dc.maxdepth.mm = smtkdive->maxdepth.mm = strtod(col[coln(MAXDEPTH)]->bind_ptr, NULL) * 1000;
}
- free(hdr_buffer);
/*
* Cylinder and gasmixes completion.
* Revisit data under some circunstances, e.g. a start pressure = 0 may mean