first report
HANDLE_LEAK.EX The handle 'debuginfod_so' is created at debuginfod-client.c:104 
by calling function 'dlopen' and lost at debuginfod-client.c:129.

second report
HANDLE_LEAK.EX The handle 'debuginfod_so' is created at debuginfod-client.c:107 
by calling function 'dlopen' and lost at debuginfod-client.c:129.

In __libdwfl_debuginfod_init, added dlclose(debuginfod_so) after symbol loading,
ensuring that the handle is released whether symbols are successfully loaded or 
not.
This prevents potential handle leak reported by static analysis.

Found by RASU JSC.

Signed-off-by: Anton Moryakov <ant.v.morya...@gmail.com>

---
 elfutils/libdwfl/debuginfod-client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/elfutils/libdwfl/debuginfod-client.c 
b/elfutils/libdwfl/debuginfod-client.c
index ee604ad..b29c455 100644
--- a/elfutils/libdwfl/debuginfod-client.c
+++ b/elfutils/libdwfl/debuginfod-client.c
@@ -125,7 +125,7 @@ __libdwfl_debuginfod_init (void)
          fp_debuginfod_find_executable = NULL;
          fp_debuginfod_find_debuginfo = NULL;
          fp_debuginfod_end = NULL;
-         dlclose (debuginfod_so);
        }
+       dlclose (debuginfod_so);
     }
 }
-- 
2.30.2

Reply via email to