[nautilus] files-view: take a ref to source object when loading directory
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] files-view: take a ref to source object when loading directory
- Date: Fri, 4 Sep 2015 21:04:34 +0000 (UTC)
commit 8117ec0dcb2227588afcb49b2a09c707e4a1be45
Author: Carlos Soriano <csoriano gnome org>
Date: Fri Sep 4 20:41:54 2015 +0200
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
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 872bd1a..5c5b158 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);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]