GNOME Bugzilla – Bug 758823
NULL dereference in g_local_file_monitor_start since 2.46
Last modified: 2016-02-18 02:24:03 UTC
The following code, introduced in 2.46, contains a NULL dereference: https://git.gnome.org/browse/glib/tree/gio/glocalfilemonitor.c#n737 In line 749, local_monitor->source is asserted to be NULL, presumably to avoid duplication. If the conditional on line 751 is met, then a reference to local_monitor->source->dirname is attempted on line 761, while local_monitor->source isn't set to a real value until line 775. Since this sequence guarantees local_monitor->source is still NULL in between, the dereference to dirname always fails. This causes an immediate crash on Cygwin when starting nautilus, and would presumably affect at least all non-Linux *NIX platforms (which only have the FAM backend, not inotify).
Created attachment 316523 [details] [review] file monitors: reorder some code to avoid segfault We must initialise '->source' before we use fields inside of it.
(In reply to Allison Ryan Lortie (desrt) from comment #1) > Created attachment 316523 [details] [review] [review] > file monitors: reorder some code to avoid segfault > > We must initialise '->source' before we use fields inside of it. True, but do local_monitor->was_mounted and/or local_monitor->mount_monitor need to be set prior to g_file_monitor_source_new()?
Review of attachment 316523 [details] [review]: looks obviously correct to me.
This was committed a while ago