GNOME Bugzilla – Bug 664537
GtkCssProvider: don't segfault when CSS file is not found
Last modified: 2011-11-30 05:25:07 UTC
gtk_css_provider_load_from_path() segfaults when the file cannot be loaded. This is because gtk_css_provider_take_error() dereferences a null pointer. Possible patch attached. Thread [1] (Suspended: Signal 'SIGSEGV' received. Description: Segmentation fault.) 14 gtk_css_provider_take_error() gtkcssprovider.c:1545 0x00007ffff731709f 13 gtk_css_provider_error() gtkcssprovider.c:1586 0x00007ffff73171d4 12 gtk_css_provider_load_internal() gtkcssprovider.c:2533 0x00007ffff7319185 11 gtk_css_provider_load_from_file() gtkcssprovider.c:2644 0x00007ffff7319501 10 gtk_css_provider_load_from_path() gtkcssprovider.c:2671 0x00007ffff73195ea 9 class_init() seahorse-widget.c:169 0x0000000000433b14 8 type_class_init_Wm() gtype.c:2219 0x00007ffff575ee06 7 g_type_class_ref() gtype.c:2925 0x00007ffff57605a9 6 g_type_class_ref() gtype.c:2917 0x00007ffff576055c 5 g_type_class_ref() gtype.c:2917 0x00007ffff576055c 4 g_object_new_valist() gobject.c:1571 0x00007ffff5745be5 3 g_object_new() gobject.c:1325 0x00007ffff57453e7 2 seahorse_key_manager_show() seahorse-key-manager.c:774 0x00000000004263ab 1 main() seahorse-main.c:101 0x00000000004264fa error->message: "Failed to import: Error opening file: No such file or directory"
Created attachment 201900 [details] [review] GtkCssProvider: don't segfault when CSS file is not found * Fix null dereference in gtk_css_provider_take_error()
Created attachment 201901 [details] [review] GtkCssProvider: don't segfault when CSS file is not found * Fix null dereference in gtk_css_provider_take_error() * And another in gtk_css_provider_emit_error()
Review of attachment 201901 [details] [review]: overall, it looks good to me. ::: gtk/gtkcssprovider.c @@ +1231,3 @@ { g_signal_emit (provider, css_provider_signals[PARSING_ERROR], 0, + scanner ? scanner->section : NULL, error); we prefer explicit NULL check for pointer comparisons, e.g.: scanner != NULL ? scanner->section : NULL
Created attachment 201932 [details] [review] Fixed pointer comparison. Okay to commit?
Review of attachment 201932 [details] [review]: Looks good
The following fix has been pushed: d462f86 GtkCssProvider: don't segfault when CSS file is not found
Created attachment 202422 [details] [review] GtkCssProvider: don't segfault when CSS file is not found * Fix null dereference in gtk_css_provider_take_error() * And another in gtk_css_provider_emit_error()