[PATCH 5/5] Clear redundant "description" when merging two cylinder types
Lubomir I. Ivanov
neolit123 at gmail.com
Sun Dec 23 17:53:28 PST 2012
From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
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 at gmail.com>
---
dive.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dive.c b/dive.c
index 8d1c716..fbe7b4a 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;
}
--
1.7.11.msysgit.0
More information about the subsurface
mailing list