From c9a698d7840fca23cbaa205262a094e4f8648bb3 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 15 Oct 2018 21:04:47 -0400 Subject: [PATCH 2/6] boot-splash: fix memory leak in error path If the splash key file fails to load, we don't free the associated key file object. This commit fixes that. --- src/libply-splash-core/ply-boot-splash.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libply-splash-core/ply-boot-splash.c b/src/libply-splash-core/ply-boot-splash.c index 87a7a0c..54f8585 100644 --- a/src/libply-splash-core/ply-boot-splash.c +++ b/src/libply-splash-core/ply-boot-splash.c @@ -181,62 +181,64 @@ void ply_boot_splash_remove_text_display (ply_boot_splash_t *splash, ply_text_display_t *display) { int number_of_columns, number_of_rows; if (splash->plugin_interface->remove_text_display == NULL) return; number_of_columns = ply_text_display_get_number_of_columns (display); number_of_rows = ply_text_display_get_number_of_rows (display); ply_trace ("removing %dx%d text display", number_of_columns, number_of_rows); splash->plugin_interface->remove_text_display (splash->plugin, display); ply_list_remove_data (splash->text_displays, display); } bool ply_boot_splash_load (ply_boot_splash_t *splash) { ply_key_file_t *key_file; char *module_name; char *module_path; assert (splash != NULL); get_plugin_interface_function_t get_boot_splash_plugin_interface; key_file = ply_key_file_new (splash->theme_path); - if (!ply_key_file_load (key_file)) + if (!ply_key_file_load (key_file)) { + ply_key_file_free (key_file); return false; + } module_name = ply_key_file_get_value (key_file, "Plymouth Theme", "ModuleName"); asprintf (&module_path, "%s%s.so", splash->plugin_dir, module_name); free (module_name); splash->module_handle = ply_open_module (module_path); free (module_path); if (splash->module_handle == NULL) { ply_key_file_free (key_file); return false; } get_boot_splash_plugin_interface = (get_plugin_interface_function_t) ply_module_look_up_function (splash->module_handle, "ply_boot_splash_plugin_get_interface"); if (get_boot_splash_plugin_interface == NULL) { ply_save_errno (); ply_close_module (splash->module_handle); splash->module_handle = NULL; ply_key_file_free (key_file); ply_restore_errno (); return false; } splash->plugin_interface = get_boot_splash_plugin_interface (); -- 2.17.1