After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 664537 - GtkCssProvider: don't segfault when CSS file is not found
GtkCssProvider: don't segfault when CSS file is not found
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkStyleContext
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-11-22 07:14 UTC by Stef Walter
Modified: 2011-11-30 05:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkCssProvider: don't segfault when CSS file is not found (938 bytes, patch)
2011-11-22 07:14 UTC, Stef Walter
none Details | Review
GtkCssProvider: don't segfault when CSS file is not found (1.28 KB, patch)
2011-11-22 07:21 UTC, Stef Walter
reviewed Details | Review
Fixed pointer comparison. Okay to commit? (1.29 KB, patch)
2011-11-22 15:34 UTC, Stef Walter
accepted-commit_now Details | Review
GtkCssProvider: don't segfault when CSS file is not found (1.29 KB, patch)
2011-11-30 05:25 UTC, Matthias Clasen
committed Details | Review

Description Stef Walter 2011-11-22 07:14:04 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"
Comment 1 Stef Walter 2011-11-22 07:14:07 UTC
Created attachment 201900 [details] [review]
GtkCssProvider: don't segfault when CSS file is not found

 * Fix null dereference in gtk_css_provider_take_error()
Comment 2 Stef Walter 2011-11-22 07:21:15 UTC
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()
Comment 3 Emmanuele Bassi (:ebassi) 2011-11-22 09:39:21 UTC
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
Comment 4 Stef Walter 2011-11-22 15:34:23 UTC
Created attachment 201932 [details] [review]
Fixed pointer comparison. Okay to commit?
Comment 5 Matthias Clasen 2011-11-23 22:00:10 UTC
Review of attachment 201932 [details] [review]:

Looks good
Comment 6 Matthias Clasen 2011-11-30 05:25:04 UTC
The following fix has been pushed:
d462f86 GtkCssProvider: don't segfault when CSS file is not found
Comment 7 Matthias Clasen 2011-11-30 05:25:07 UTC
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()