]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
client: call cleanup functions everytime we return from main
authorEric Curtin <ecurtin@redhat.com>
Mon, 28 Mar 2022 14:52:49 +0000 (15:52 +0100)
committerRay Strode <halfline@gmail.com>
Mon, 28 Mar 2022 15:25:50 +0000 (15:25 +0000)
We were not cleaning up allocated resources in many of the code
execution paths in main()

src/client/plymouth.c

index 304ea8e23fcc66ed3a6c387eb56c5782158e5bb4..c23133683b51c687c7bc07eb19a188ece30d5c23 100644 (file)
@@ -1065,7 +1065,8 @@ main (int    argc,
                 ply_error ("%s", help_string);
 
                 free (help_string);
-                return 1;
+                exit_code = 1;
+                goto out;
         }
 
         ply_command_parser_get_options (state.command_parser,
@@ -1097,7 +1098,7 @@ main (int    argc,
                         printf ("%s", help_string);
 
                 free (help_string);
-                return 0;
+                goto out;
         }
 
         if (ply_kernel_command_line_has_argument ("plymouth.debug") && !ply_is_tracing ())
@@ -1108,7 +1109,7 @@ main (int    argc,
 
         if (should_get_plugin_path) {
                 printf ("%s\n", PLYMOUTH_PLUGIN_PATH);
-                return 0;
+                goto out;
         }
 
         is_connected = ply_boot_client_connect (state.client,
@@ -1119,15 +1120,17 @@ main (int    argc,
 
                 if (should_ping) {
                         ply_trace ("ping failed");
-                        return 1;
+                        exit_code = 1;
+                        goto out;
                 }
                 if (should_check_for_active_vt) {
                         ply_trace ("has active vt? failed");
-                        return 1;
+                        exit_code = 1;
+                        goto out;
                 }
                 if (should_wait) {
                         ply_trace ("no need to wait");
-                        return 0;
+                        goto out;
                 }
         }
 
@@ -1215,6 +1218,9 @@ main (int    argc,
 
         exit_code = ply_event_loop_run (state.loop);
 
+out:
+        ply_command_parser_free (state.command_parser);
+
         ply_boot_client_free (state.client);
 
         ply_event_loop_free (state.loop);