From f80684387a0371d69df155d9d2bde058371c5aa2 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 10 Aug 2015 10:11:32 -0400 Subject: [PATCH] boot-splash: don't crash in free if module not loaded ply_boot_splash_free currently calls some code that depends on a module being loaded. We call ply_boot_splash_free to clean up the boot splash object if a module can't be loaded, leading to crash. This commit addresses that issue by only calling the module specific destruction code in ply_boot_splash_free in the case where a module is loaded. https://bugs.freedesktop.org/show_bug.cgi?id=91590 --- src/libply-splash-core/ply-boot-splash.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libply-splash-core/ply-boot-splash.c b/src/libply-splash-core/ply-boot-splash.c index e853e1f..87a7a0c 100644 --- a/src/libply-splash-core/ply-boot-splash.c +++ b/src/libply-splash-core/ply-boot-splash.c @@ -374,70 +374,71 @@ remove_text_displays (ply_boot_splash_t *splash) 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); node = next_node; } } void ply_boot_splash_free (ply_boot_splash_t *splash) { ply_trace ("freeing splash"); if (splash == NULL) return; if (splash->loop != NULL) { if (splash->plugin_interface->on_boot_progress != NULL) { ply_event_loop_stop_watching_for_timeout (splash->loop, (ply_event_loop_timeout_handler_t) ply_boot_splash_update_progress, splash); } ply_event_loop_stop_watching_for_exit (splash->loop, (ply_event_loop_exit_handler_t) ply_boot_splash_detach_from_event_loop, splash); } - ply_boot_splash_unset_keyboard (splash); + if (splash->module_handle != NULL) { + ply_boot_splash_unset_keyboard (splash); - remove_pixel_displays (splash); - ply_list_free (splash->pixel_displays); + remove_pixel_displays (splash); + ply_list_free (splash->pixel_displays); - remove_text_displays (splash); - ply_list_free (splash->text_displays); + remove_text_displays (splash); + ply_list_free (splash->text_displays); - if (splash->module_handle != NULL) ply_boot_splash_unload (splash); + } if (splash->idle_trigger != NULL) ply_trigger_free (splash->idle_trigger); free (splash->theme_path); free (splash->plugin_dir); free (splash); } static void ply_boot_splash_update_progress (ply_boot_splash_t *splash) { double percentage = 0.0; double time = 0.0; assert (splash != NULL); if (splash->progress) { percentage = ply_progress_get_percentage (splash->progress); time = ply_progress_get_time (splash->progress); } if (splash->plugin_interface->on_boot_progress != NULL) splash->plugin_interface->on_boot_progress (splash->plugin, time, percentage); ply_event_loop_watch_for_timeout (splash->loop, 1.0 / UPDATES_PER_SECOND, (ply_event_loop_timeout_handler_t) -- 2.4.3