[PATCH 2/5] irmd: Fix memory leak of ret_msg

  • From: Dimitri Staessens <dimitri@ouroboros.rocks>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Fri, 25 Feb 2022 00:15:29 +0100

The ret_msg variable can leak in the main loop of the irmd in this
failure path.

Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
---
 src/irmd/main.c       | 1 +
 src/irmd/prog_table.c | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/irmd/main.c b/src/irmd/main.c
index a87f191a..f83e8e1e 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -2078,6 +2078,7 @@ static void * mainloop(void * o)
                 if (msg == NULL) {
                         close(sfd);
                         irm_msg__free_unpacked(msg, NULL);
+                        free(ret_msg);
                         continue;
                 }
 
diff --git a/src/irmd/prog_table.c b/src/irmd/prog_table.c
index eb2b1966..4b43626c 100644
--- a/src/irmd/prog_table.c
+++ b/src/irmd/prog_table.c
@@ -110,8 +110,7 @@ void prog_entry_del_name(struct prog_entry * e,
                 struct str_el * s = list_entry(p, struct str_el, next);
                 if (!strcmp(name, s->str)) {
                         list_del(&s->next);
-                        if (s->str != NULL)
-                                free(s->str);
+                        free(s->str);
                         free(s);
                 }
         }
-- 
2.35.1


Other related posts:

  • » [PATCH 2/5] irmd: Fix memory leak of ret_msg - Dimitri Staessens