From aa8ed92fba93f6213eab8f50754f427550797bfc Mon Sep 17 00:00:00 2001
From: Maxim Moskalets <Maxim.Moskalets@kaspersky.com>
Date: Sat, 3 Feb 2024 15:16:56 +0300
Subject: [PATCH] gresources: fix memory leak from libelf

Memory was leaking when allocating it inside libelf and losing the pointer to it (it was an automatic variable) when returning NULL from the get_elf function in some cases

Closes #3242

Signed-off-by: Maxim Moskalets <Maxim.Moskalets@kaspersky.com>
---
 gio/gresource-tool.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gio/gresource-tool.c b/gio/gresource-tool.c
index fa7bdedb55..44b1f3f028 100644
--- a/gio/gresource-tool.c
+++ b/gio/gresource-tool.c
@@ -165,6 +165,7 @@ get_elf (const gchar *file,
 
   if (elf_kind (elf) != ELF_K_ELF)
     {
+      elf_end (elf);
       g_close (*fd, NULL);
       *fd = -1;
       return NULL;
-- 
GitLab

