[PATCH 5/5] rtl-shell.c: Resource leak (CID #1444140)

Ryan Long ryan.long at oarcorp.com
Fri Mar 12 15:18:46 UTC 2021


CID 1444140: Resource leak in rtems_rtl_shell_object().

Closes #4300
---
 cpukit/libdl/rtl-shell.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cpukit/libdl/rtl-shell.c b/cpukit/libdl/rtl-shell.c
index 9f8a136..bcecdd4 100644
--- a/cpukit/libdl/rtl-shell.c
+++ b/cpukit/libdl/rtl-shell.c
@@ -733,14 +733,17 @@ rtems_rtl_shell_object (const rtems_printer* printer, int argc, char* argv[])
     if (dlinfo (RTLD_SELF, RTLD_DI_UNRESOLVED, &unresolved) < 0)
     {
       rtems_printf (printer, "error: %s: %s\n", argv[arg], dlerror ());
+      (void) dlclose (handle);
       return 1;
     }
 
     if (unresolved != 0)
     {
       rtems_printf (printer, "warning: unresolved symbols present\n");
+      (void) dlclose (handle);
       return 1;
     }
+  (void) dlclose (handle);
   }
   else if (strcmp (argv[arg], "unload") == 0)
   {
-- 
1.8.3.1



More information about the devel mailing list