From 2350ef111173d24bfc41b7a8eedc1ed021636320 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 14 Feb 2024 23:58:16 +0000 Subject: [PATCH] main: Return from flatpak_run() instead of calling exit() This allows g_autoptr destructors to run, avoiding memory leaks being reported by AddressSanitizer; they would be harmless, since we're about to exit anyway, but AddressSanitizer can't tell the difference between an O(n) problem and an O(1) harmless "leak". Signed-off-by: Simon McVittie --- app/flatpak-main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/flatpak-main.c b/app/flatpak-main.c index 56bb48a9..0918c6f5 100644 --- a/app/flatpak-main.c +++ b/app/flatpak-main.c @@ -711,13 +711,13 @@ flatpak_run (int argc, if (opt_version) { g_print ("%s\n", PACKAGE_STRING); - exit (EXIT_SUCCESS); + return EXIT_SUCCESS; } if (opt_default_arch) { g_print ("%s\n", flatpak_get_arch ()); - exit (EXIT_SUCCESS); + return EXIT_SUCCESS; } if (opt_supported_arches) @@ -726,7 +726,7 @@ flatpak_run (int argc, int i; for (i = 0; arches[i] != NULL; i++) g_print ("%s\n", arches[i]); - exit (EXIT_SUCCESS); + return EXIT_SUCCESS; } if (opt_gl_drivers) @@ -735,7 +735,7 @@ flatpak_run (int argc, int i; for (i = 0; drivers[i] != NULL; i++) g_print ("%s\n", drivers[i]); - exit (EXIT_SUCCESS); + return EXIT_SUCCESS; } if (opt_list_installations) @@ -751,7 +751,7 @@ flatpak_run (int argc, GFile *file = paths->pdata[i]; g_print ("%s\n", flatpak_file_get_path_cached (file)); } - exit (EXIT_SUCCESS); + return EXIT_SUCCESS; } } @@ -777,7 +777,7 @@ flatpak_run (int argc, if (local_error != NULL) { g_printerr ("%s\n", local_error->message); - exit (1); + return 1; } for (gsize i = 0; i < system_installation_locations->len; i++) @@ -805,7 +805,7 @@ flatpak_run (int argc, new_dirs_joined = g_strjoinv (":", (gchar **) new_dirs->pdata); g_print ("XDG_DATA_DIRS=%s\n", new_dirs_joined); - exit (EXIT_SUCCESS); + return EXIT_SUCCESS; } }