From fd03fcd66dae7e1e909a29639f01b4b5368f3877 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Mon, 24 Dec 2012 03:53:28 +0200 Subject: 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 Signed-off-by: Dirk Hohndel --- dive.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'dive.c') 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; } -- cgit v1.2.3-70-g09d2