metrics: fix a memleak 74/240474/1
authorMichal Bloch <m.bloch@samsung.com>
Thu, 6 Aug 2020 11:55:58 +0000 (13:55 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 6 Aug 2020 12:10:13 +0000 (14:10 +0200)
Change-Id: Iab097759f8317ed2a39699a1a5a0ab5f33cd895e
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
include/metrics.h
src/shared/metrics.c

index ab40f53..478b00a 100644 (file)
@@ -30,7 +30,7 @@ void metrics_destroy(struct metrics *);
 bool metrics_add_log(struct metrics *, const dlogutil_entry_s *);
 
 struct metrics_info {
-       const char *tag;
+       char *tag;
        pid_t pid;
        int count[DLOG_PRIO_MAX];
 };
index fdce6df..e37caf6 100644 (file)
@@ -43,6 +43,9 @@ void metrics_destroy(struct metrics *m)
        if (!m)
                return;
 
+       for (int i = 0; i < m->count; ++i)
+               free(m->inner[i].tag);
+
        free(m->inner);
        free(m);
 }