summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2012-12-24 03:53:28 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-27 08:15:25 -0800
commitfd03fcd66dae7e1e909a29639f01b4b5368f3877 (patch)
treed0bdeefca476c80d16a5666f75381e6ad87c9de7 /dive.c
parent310b05ac84961ca15643d92b41ee14d392e133d8 (diff)
downloadsubsurface-fd03fcd66dae7e1e909a29639f01b4b5368f3877.tar.gz
Clear redundant "description" when merging two cylinder types
dive.c: merge_cyclinder_type() can cause a small memory leak if two cylinder types are about to be merged, but the redundant one has a "description" string allocated. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/dive.c b/dive.c
index 8d1c71639..fbe7b4a64 100644
--- a/dive.c
+++ b/dive.c
@@ -815,8 +815,13 @@ static void merge_events(struct divecomputer *res, struct divecomputer *src1, st
/* Pick whichever has any info (if either). Prefer 'a' */
static void merge_cylinder_type(cylinder_type_t *res, cylinder_type_t *a, cylinder_type_t *b)
{
- if (a->size.mliter)
+ cylinder_type_t *clean = a;
+ if (a->size.mliter) {
+ clean = b;
b = a;
+ }
+ if (clean->description)
+ free((void *)clean->description);
*res = *b;
}