diff options
author | Carlos Soriano <csoriano@gnome.org> | 2015-09-04 20:41:54 +0200 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2015-09-04 23:03:45 +0200 |
commit | 8117ec0dcb2227588afcb49b2a09c707e4a1be45 (patch) | |
tree | 199dd6bb00a3beddfe307093dc1ba6a133db179d | |
parent | 9ab3c5c7d7f7162193559ad643707dc1a2bc69fc (diff) | |
download | nautilus-8117ec0dcb2227588afcb49b2a09c707e4a1be45.tar.gz |
files-view: take a ref to source object when loading directory
We were calling load_directory with the current model, but the view
expect to own it's own reference to the model, and the caller to own
it's own one to the source object.
However, when we use that internally, we were just using the current
model withouth taking an aditional reference, which was causing a
use-after-free crash.
To avoid it, if we are going to us public functions internally, take a
reference to the source object like a external client would have.
https://bugzilla.gnome.org/show_bug.cgi?id=754310
-rw-r--r-- | src/nautilus-files-view.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index 872bd1a08..5c5b1588a 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -2316,6 +2316,12 @@ nautilus_files_view_set_show_hidden_files (NautilusFilesView *view, show_hidden); if (view->details->model != NULL) { + /* We have to simulate that we are a client asking to swtich to a new + * location, and of course we have our own ref to it. In this + * case, the client (this function) and the server (the view) has the same + * reference, and the server will unref its current model, giving + * a "use after free" crash. So take a ref here. */ + nautilus_directory_ref (view->details->model); load_directory (view, view->details->model); } } |