GNOME Bugzilla – Bug 688430
file-manager: Fix invalid unref of NULL pointer.
Last modified: 2012-11-17 11:15:50 UTC
As summary says.
Created attachment 229102 [details] [review] file-manager: Fix invalid unref of NULL pointer.
Review of attachment 229102 [details] [review]: Thanks for your patch Here is the corresponding code: do { GFile* model_file; gtk_tree_model_get (GTK_TREE_MODEL(model), &file_iter, COLUMN_FILE, &model_file, -1); if (model_file && file && g_file_equal (model_file, file)) { g_object_unref (model_file); found = TRUE; break; } g_clear_object (&model_file); } while (gtk_tree_model_iter_next (GTK_TREE_MODEL(model), &file_iter)); I think a better solution will be to initialized model_file to NULL and keep the g_object_unref. Using g_clear_object does not fix the issue for the first loop iteration. Do you agree?
The gtk_tree_model_get() will set model_file to a valid file or NULL. Using g_clear_object() or "if (model_file) g_object_unref (model_file)" is both ok. Which one to choose is purely stylistic in this case.
Review of attachment 229102 [details] [review]: Ok, I have missed it, then your patch is just fine. Thanks.