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>
This commit is contained in:
Lubomir I. Ivanov 2012-12-24 03:53:28 +02:00 committed by Dirk Hohndel
parent 310b05ac84
commit fd03fcd66d

7
dive.c
View file

@ -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;
}